Condensed verions of chat follows:
Phill said:
Max suggested I use a callback called 'onlastframe'. I'm looking at
LzSprite.prototype.play = function(f) for guidance. I was planning on
making a playonce version. I still hadn't determined how to
differentiate between .play and .playonce. It seems that the default
behavior in SWF is that it loops (?) so perhaps loop should be the
default. lzx code could specify an attribute from the set {loop |
once | static} to change the behavior.
Tucker said:
This seems to me to be an essential part of the Sprite API, whether a
multi-frame resource auto-plays and whether it loops. It seems to me
this should be settable and the Sprite API needs to support it. I
think Max needs to be 'in the loop' here. Let's start either an email
or skype conversation with max in the loop. the sprite api is really
his baliwick
Naively, I would say there should just be two attributes, autoplay
and loop which get implemented in the sprite
-------------------------------
How would I do one of the following?
Define sprite attributes. Set their default initializations and
allowable values in LZX. Read their values in the javascript below?
Insure that play is called upon sprite initialization in all of SWF,
DHTML, etc..
Define sprite attributes. Set their default initializations and
allowable values in LZX. Cause the attribute value to control the
choice of play method to execute upon sprite initialization?
The former is preferable because we can then have a single play
method that behaves differently depending on the attributes of the
sprite.
What's the relationship between the 4 versions of
LzSprite.Prototype.play I found (LzSprite.js, LzSprite.as, LFCdhtml-
debug.js, and LFCdhtml-profile.js)? Is LzSprite.js the source for the
others, which are automatically generated?
Is it an error to remove a callback which has not been added?
Here is my first cut at playonce. Is this what I want?
LzSprite.prototype.playonce = function(f) {
if (isNaN(f * 1) == false) {
//Debug.info('playonce ' + f + ', ' + this.frame);
this.__setFrame(f);
}
if (this.playing == true) return;
if (this.frames && this.frames.length > 1) {
this.playing = true;
LzIdleKernel.addCallback(this, '__onlastframe');
LzIdleKernel.addCallback(this, '__incrementFrame');
}
}
LzSprite.prototype._onLastFrame = function() {
this.stop();
}
LzSprite.prototype.stop = function(f) {
if (this.playing == true) {
this.playing = false;
LzIdleKernel.removeCallback(this, '__incrementFrame');
LzIdleKernel.removeCallback(this, '__onlastframe');
}
if (isNaN(f * 1) == false) {
//Debug.info('stop ' + f + ', ' + this.frame);
this.__setFrame(f);
}
}
Phillip G. Apley
Senior Software Engineer
Platform Team
Laszlo Systems, Inc.
[EMAIL PROTECTED]
[EMAIL PROTECTED]
maynard: 978-298-5210
allston: 617-787-2831
cell: 617-283-1717
skype: phillipapley
aim: phillipapley
jabber: [EMAIL PROTECTED]
irc: [EMAIL PROTECTED]
icq: 258643767
On Dec 5, 2006, at 1:41 PM, Max Carlson wrote:
Phillip George Apley wrote:
I'm working on noughts and crosses, and I find that the multiframe
resources animate forever in DHTML. They should just play once.
I find this function in LzScript.js:
LzSprite.prototype.play = function(f) {
if (isNaN(f * 1) == false) {
//Debug.info('play ' + f + ', ' + this.frame);
this.__setFrame(f);
}
if (this.playing == true) return;
if (this.frames && this.frames.length > 1) {
this.playing = true;
LzIdleKernel.addCallback(this, '__incrementFrame');
}
}
I'm thinking this same play function is being used for swf or png,
dhtml or swf8. Is that right? Do I have to make another version of
this for DHTML which uses a different callback so it will stop
animating? Since some png resources will want to play forever and
others to play once, do we add something to the resource
descriptor (copied out of the swf?), or do we have a different API
call.
There should be an 'onlastframe' event you can listen for and call
stop()...
--
Regards,
Max Carlson
OpenLaszlo.org