Skip to main content
Participating Frequently
May 1, 2010
Answered

How to stop the animation at a certain frame?

  • May 1, 2010
  • 2 replies
  • 8118 views

Well, as the title already says, how can I stop my animtation at a certain frame. Is it only possible due setting up a timer, or can I also enter a code that stops at a certain frame?

And when I stop the animation, will my buttons still be able to get clicked?

Greetings,

Coyke

This topic has been closed for replies.
Correct answer Andrei1-bKoviI

Well, as the title already says, how can I stop my animtation at a certain frame. Is it only possible due setting up a timer, or can I also enter a code that stops at a certain frame?

Here is what need to do in general:

addEventListener(Event.ENTER_FRAME, onEnterFrame);

function onEnterFrame(e:Event):void {
     if (currentFrame == 200) stop();
}

And when I stop the animation, will my buttons still be able to get clicked?

If the button is on stage on the frame - it will be available to interactions.

2 replies

Andrei1-bKoviICorrect answer
Inspiring
May 1, 2010

Well, as the title already says, how can I stop my animtation at a certain frame. Is it only possible due setting up a timer, or can I also enter a code that stops at a certain frame?

Here is what need to do in general:

addEventListener(Event.ENTER_FRAME, onEnterFrame);

function onEnterFrame(e:Event):void {
     if (currentFrame == 200) stop();
}

And when I stop the animation, will my buttons still be able to get clicked?

If the button is on stage on the frame - it will be available to interactions.

CoykeAuthor
Participating Frequently
May 1, 2010

Thanks Andrei1, this code totally solved my problem!

For the others that responded, thanks for your usefull answers!

Inspiring
May 1, 2010

You are welcome.


May 1, 2010

You can use a command stop(); in the frame you want to stop. In case of buttons - it depends on how you have implemented them. Try and post some code if there occur problems with buttons.

Regards,

gc

CoykeAuthor
Participating Frequently
May 1, 2010

Thanks for the usefull reply, the problem was that i forgot the add a new keyframe that's why I couldnt make it in the frame I wanted.

I will have between 15 and 20 buttons that need to be able to get clicked when my animation is stopped, I first imported them to my library, then placed everything where I wanted it to be. Then created them as a Symbol (Selected Button!). Then I created instance names for every single of them.

With the code that's downstairs I want to let my animation go to frame 200 when I click on the button "Middenknop" while the animation is paused. But now i get this error:

TypeError: Error #1009: Kan geen eigenschap of methode benaderen via  een verwijzing naar een object dat null is.
     at Animatie2_fla::MainTimeline/frame1()

Here's the code I am currently using:

import flash.events.MouseEvent;

//---Middenknop eigenschap verandering---\\

Middenknop.addEventListener(MouseEvent.CLICK, basisClick);

function basisClick(event:MouseEvent):void{
    gotoAndPlay(200);
}

New Participant
May 1, 2010

Please tell it which object would go to  frame 200 .For example, your animation is named " mc_Anim ", I would write it like this: mc_Anim.gotoAndStop(200).