Flash CS3 - how to stop a frame

canimbenim picture canimbenim · May 4, 2011 · Viewed 23.1k times · Source

I created on first frame menu. On second frame there is all my game. I use button to change the frames:

button1.addEventListener(MouseEvent.MOUSE_DOWN, startGame1);

function startGame1(e:MouseEvent)
{
    howManyPlayers = 1;

    gotoAndStop(2);

}

But The frame 1 is still working and I can see it. Is any possibility to:

  1. turn off/stop the frame 1
  2. turn off all layer?
  3. or any other technique which I use in this situation?

Answer

Flavius Frantz picture Flavius Frantz · May 4, 2011

to stop the animation at a certain frame in the timeline with actionScript 3 is very simple, all you need to do is to add this code to your frame :

stop();

my best guess is that you don't have a "stop();" on your first frame and the animation simply starts playing from the begining looping through the frames, what you want it to do is to stop on the first frame where you have your "button1" and then when you click the button1 you want the animation to jump to frame 2, just add this to your code in frame 1 :

stop();

this way the animation is stopped from the begining on frame 1 where you have your "button1" and then when the user clicks your button it jumps into your code example and it goes to frame 2 and stops, if it doen't stop, which sometimes may happen just add another: stop(); on your frame 2 also.