
All movieclips in the same fla play at the same speed fps.
If there is only one frame in the main/_root timeline,
the movie just sits there, and any nested clips (ball tween)
keep on playing for as long as needed.
If you move this keyframe to frame 3 without adding a stop()
to that frame, the main timeline plays 123, loops back to 1, plays 123, etc…
But if you then add 10 frames, these 10 frames give the balltween, which is also 10 frames, enough time to finish playing before the main timeline loops back.
Instead of your gotoandPlay, try the stop() on frame 3/main instead, remove the other 10 frames…
Is this a bit clearer? It’s a weird concept at start, with all this nesting, that’s why it’s good to learn some basic AS commands at the same time.
Example: add stop() to frame 1 of ball: it does not play.
add button to the MAIN timeline/ frame 3 (which also has it’s stop() now!), instance name : button_btn.
how to get the ball to play by clicking on the button?
target the ball clip (let’s say instance name = ball_mc) and tell it to play:
[AS]button_btn.onRelease = function(){
ball_mc.play();
} //mx style, so in frame 3, not on the button![/AS]
Now, select the button, hit f8, select clip => you now have a clip with the button inside. first thing, as you’ll need to talk to the clip, select it on stage and give it an instance name, let’s say btnCont_mc.
How to get the AS in frame 3 for the button to work again?
Change the target to accomodate it’s new location: button is now in btnclip, so you get:
[AS]btnCont_mc.button_btn.onRelease = function(){
ball_mc.play();
} [/AS]
Ok, i changed the path to reflect the buttons new location, but the ball doesn’t play!?
Yes, but did you also change the path to ball? ball is NOT in btnCont_mc, where Flash looks for it coz that’s where the button calling the script is, so you have to use:
[AS]btnCont_mc.button_btn.onRelease = function(){
_parent.ball_mc.play(); //one level up
}
//or:
btnCont_mc.button_btn.onRelease = function(){
_root.ball_mc.play(); //ball is in the _root level
}
[/AS]
but you could just as well place this script instead inside btnCont.mc (bad practice!):
[AS] button_btn.onRelease = function(){ //notice “btnCont_mc.” is gone
_root.ball_mc.play(); //still need to go back to _root to get ball!
} [/AS]
Getting clearer? (or more confused…
)
###Bonus:###
Now, if by mistake, you placed button in frame 1 of the main timeline, what happens?
Nothing, coz frame 3 is a keyframe, that means new content from the previous frames, so button will be present in frames 1 and 2 (no keyframe in 2), but not in 3.
Flash elements (buttons, clips, textfields…) can only talk to any other elements present on the timeline at the same time (= in the same frame (not going into functions here…), and as ball exists only from frame 3, no way button, which then doesn’t exist anymore, can talk to it!
So: 1 frame: the clip stays there, nested content plays.
More than 1: need stop() 's where you want it to stop, and then target the stuff you want to play…
Hope this helps.