Skip to main content
September 5, 2012
Question

My swf plays only twice and stops.

  • September 5, 2012
  • 2 replies
  • 652 views

I created a simple flash file to use on my website. It's just 2 frames and has arrows to go to the next picture. It works perfectly fine for like 2 times then the buttons just stop working. I have no idea why it's doing that. Any help would be appreciated. I'm running Adobe Professional CS5 and Actionscript 3.0

Here's the file:   http://www.mediafire.com/?aiowqvap6waic75

This topic has been closed for replies.

2 replies

Ned Murphy
Legend
September 5, 2012

1) Change the code you have in frame 1 to:

stop();


var nextF = 2;
var prevF = 2;

larrow.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_5);

function fl_ClickToGoToAndPlayFromFrame_5(event:MouseEvent):void
{
     gotoAndPlay(prevF);
}

rarrow.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_6);

function fl_ClickToGoToAndPlayFromFrame_6(event:MouseEvent):void
{
     gotoAndPlay(nextF);
}

2) Change your code in frame 2 to:

stop();

nextF = 1;

prevF = 1;

3) Change your layer with the arrow control so that it only has the one keyframe in frame 1 so that the same button instances are used along the entire timeline.  The easiest way to do this is to right click frame two of that layer and choose Clear Keyframe.

If you need to add more frames, just use the code in frame 2 and adjust the values of prevF and nextF to suit where you want things to go.

The problem with what you had before is that you end up assigning both listeners for the two frames to the buttons, so when you click one after both have been assigned, both functions get executed.  With the changes above you only ever have one function for each button.

Ned Murphy
Legend
September 5, 2012

You'll better your chances of getting help if you don't ask people to download files and instead explain your design and show the code that is relevant to the problem.

What is the code your file is using for the buttons and how is it set up in the file?