beginSprite will be called by Director when the play head enters the spriteSpan.
If you have a behavior that you want to attach on the fly, you can also write a "new" handler in the script, but it will NOT be called automatically. It only executes if you call the "new" handler specifically.
I think the ideal way to handle this is something like this:
property spriteNum
-- If behavior is added on the fly, you must call this and pass the channel on new me me, whichChannel spriteNum = whichChannel me.CommonStartUpCode() end
on beginSprite me me.CommonStartUpCode() end
on CommonStartUpCode me -- here you put any code that you want to execute when starting up, end
Irv
At 9:04 AM -0700 9/11/03, [EMAIL PROTECTED] wrote:
Quoting Evan Adelman <[EMAIL PROTECTED]>:When generating objects of scripts on the fly to attach to sprites, you're actually invoking the 'new' handler, not the beginSprite handler:
xCursor = (script "flaCursorScript").new(2)
Evan is right, but I'd like to add something.
If you have a script already attached to a sprite (presumably attached during authoring), if it has an "on new" handler _and_ an "on beginSprite" handler, both will execute. New executes first, then beginSprite.
That's not contradicting Evan. He's right about the order when you attach a behavior at runtime. When it's attached during authoring, it's different.
Cordially,
Kerry Thompson
--
Multimedia Wrangler. [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]
