PDA

View Full Version : [simple] first do "something", when complete do something else



omgnoseat
May 19th, 2009, 03:42 PM
Right, like the topic states I got quite a simple question that I can't figure out myself.

I have a movieclip with an animation in it, animation1 for now. At frame 15 of that animation there is another movieclip, animation2. When animation 1 is done, animation 2 should play from frame 2.

When I press a button, animation 1 plays and stops at frame 15, from there the animation 2 should play from frame 2.

Quite easy.. but can't figure it out without getting errors =/


//event listeners
button.addEventListener(MouseEvent.CLICK, playAnimation);

function playAnimation(event:MouseEvent):void {
Animation1.gotoAndPlay(2);
//somehow play animation 2 when animation 1 is done
Animation1.Animation2.gotoAndStop(2);
}

Hope anyone can clear this up for me :)

sebrofm
May 19th, 2009, 03:54 PM
Animation1.addEventListener(Event.ENTER_FRAME, checkFrame);
function checkFrame(e:Event) : void {
if (e.target.currentFrame == 15){
Animation2.gotoAndStop(2);
}
}