I have a question about if a animation ends that it will like gotoAndStop()
to another frame
if (bird.hitTestObject(pipe1)) {
bird.gotoAndStop(3); //frame 3 = animation
}
after it ends it will need to go the Game Over frame (frame 3) and I use the Flash Timeline
not .as
thanks!
The question is not clear, but you can attach ActionScript code to keyframes. Simply put, when the playhead hits that frame, that code will be executed. In Flash Professional, just click on the keyframe where your animation ends, open up the "Actions" panel and write whatever code you need to be executed when the animation ends.
eg If you have a MovieClip
placed on the stage having (say 60 frames) of animation.
Now, on the Main Timeline (ie Stage Timeline) you want to go to keyframe no.3 but only after animation in the above MovieClip
is finished (ie if it's on 60th keyframe
), then add the following line to the last keyframe
(here 60 th) of that MovieClip
like so,
MovieClip(this.parent).gotoAndStop(3);
// here this.parent
refers to Stage Timeline
In your case (Question is not clear though) it might be,
MovieClip(this.parent).bird.gotoAndStop(3);
Some more examples for understanding,
MovieClip(this.parent).score;
//Accessing Score
from main Timeline. MovieClip(this.parent.parent).health;
//Nested clips
But I do not recommend this approach as It gets harder to debug and maintain as Projects get larger. Instead use OOP
, MVC
like pattern and for animation use TweenLite
for example.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.