Re: lingo-l on beginSprite used in frame scripts
I believe that you are mistaken. At 10:09 PM +1100 3/30/02, you wrote: Hi all, I've made some discoveries and am a little baffled. When looping in one frame: -- Using the 'on prepareFrame' handler in the frame script will execute the commands within it every time the frame loops. true - frame events happen on each frame that they are able to (as designed) Using the 'on prepareFrame' handler in a sprite script will execute the commands within it only once. nope - they happen on every frame of the sprite - that's one of the differences between it beginSprite, which only fires in the first frame of the sprite. Using the 'on beginSprite' handler in a sprite script will execute the commands within it only once. as it should Using the 'on beginSprite' handler in the frame script will execute the commands within it only once. as it should Up until now I have been using the 'on prepareFrame' handler in frame scripts, but to prevent it from re-executing the commands within it every time the frame loops I have been setting a variable to prevent this from happening more than once. Example --- global framePrepared on startMovie framePrepared = 0 end on prepareFrame me if framePrepared = 0 then framePrepared = 1 code to be executed code to be executed code to be executed end if end I hope these aren't within the same script member. the startMovie handler belongs in a movie script the prepareFrame handler is usually in either a sprite behavior or a frame script (in the frame channel) I hope that you aren't coming to your conclusions based on how sprites behave in frame 1 behave because they have slightly different event firings in that frame compared to all other frames. What I'm getting at is what is the purpose of the 'on prepareFrame' handler when the 'on beginSprite' handler can be used in a frame script? the beginSprite for the frame script occurs after the beginsprite events for each of the 1-n sprites. Is the 'on beginSprite' handler meant to be used in a frame script? it can, but it rarely is. Or an 'on prepareFrame' handler to be used in a sprite script for that matter? not usually, since it fires on each frame. people use on enterFrame to do things at the beginning of each frame (see most of the behaviors in the Behavior Library) hth -Buzz Drekinn It's not a bug, it's a random feature. [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!] [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!]
Re: lingo-l on beginSprite used in frame scripts
What I'm getting at is what is the purpose of the 'on prepareFrame' handler when the 'on beginSprite' handler can be used in a frame script? Is the 'on beginSprite' handler meant to be used in a frame script? Or an 'on prepareFrame' handler to be used in a sprite script for that matter? Drekinn I'm not sure of when to use the prepareFrame handler, but I can tell you I use on beginSprite in both frame and sprite behaviors all the time. -A. [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!]
Re: lingo-l on beginSprite used in frame scripts
Tom Hines wrote: What I'm getting at is what is the purpose of the 'on prepareFrame' handler when the 'on beginSprite' handler can be used in a frame script? Is the 'on beginSprite' handler meant to be used in a frame script? Or an 'on prepareFrame' handler to be used in a sprite script for that matter? Hey Tom, You right that on beginsprite only fires once. When the sprite is first born onto the stage. This is a good place to run code to initialize the sprite. On beginsprite can be used with either frame scripts or on actual sprites.Same with the on prepareFrame, or on enter/exitFrame for that matter. They aren't limited to being placed only in frame scripts. If you have a ball sitting on the stage and you want it to animate then drop a behaviour on it that uses on prepareFrame to execute the animation. on prepareFrame me sprite(me.spriteNum).locH=sprite(me.spriteNum).locH+1 end And again you can use a flag to turn the animation on and off. Have you experimented much with behaviours? Understand what properties are? If not read up on them, very powerful stuff. HTH Rob [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!]
Re: lingo-l on beginSprite used in frame scripts
What you've written doesn't match my experience. Specifically, when you said, Using the 'on prepareFrame' handler in a sprite script will execute the commands within it only once. So, I built a test case - a small movie that only has two scripts. As the frame script for frame 1, I wrote: on prepareFrame me put in prepareFrame of Frame script end on beginSprite me put in beginSprite of Frame script end on exitFrame me go to the frame end I put a simple graphic in channel 1 of frame 1 and added the following script: on prepareFrame me put in prepareFrame of script channel end on beginSprite me put in beginSprite of script channel end Then I ran the program. Here is the output from the message window: -- in beginSprite of Frame script -- in beginSprite of script channel -- in prepareFrame of script channel -- in prepareFrame of Frame script -- in prepareFrame of script channel -- in prepareFrame of Frame script -- in prepareFrame of script channel -- in prepareFrame of Frame script -- in prepareFrame of script channel -- in prepareFrame of Frame script -- in prepareFrame of script channel -- in prepareFrame of Frame script -- in prepareFrame of script channel -- in prepareFrame of Frame script -- in prepareFrame of script channel -- in prepareFrame of Frame script -- in prepareFrame of script channel -- in prepareFrame of Frame script -- in prepareFrame of script channel -- in prepareFrame of Frame script As expected, the beginsprites from both the frame and script channels execute once, but the prepareFrame scripts BOTH execute every frame event. As others have stated, the on beginsprite in any frame or script channel script is a great place to put initialization code. (And using the on endSprite is a great place to put any clean up code.) Irv At 10:09 PM +1100 3/30/02, Tom Hines wrote: Hi all, I've made some discoveries and am a little baffled. When looping in one frame: -- Using the 'on prepareFrame' handler in the frame script will execute the commands within it every time the frame loops. Using the 'on prepareFrame' handler in a sprite script will execute the commands within it only once. Using the 'on beginSprite' handler in a sprite script will execute the commands within it only once. Using the 'on beginSprite' handler in the frame script will execute the commands within it only once. -- Lingo / Director / Shockwave development for all occasions. (Home-made Lingo cooked up fresh every day just for you.) [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!]
Re: lingo-l on beginSprite used in frame scripts
What you've written doesn't match my experience. Specifically, when you said, Using the 'on prepareFrame' handler in a sprite script will execute the commands within it only once. So, I built a test case - a small movie that only has two scripts. As the frame script for frame 1, I wrote: I'm surprised you even tested it. I read the earlier messages (they're at home, so I can't check), but the way I read it made it clear that beginsprite was once, and prepareframe was every time. Could you post a quote of the confusing part? -- [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!]