Skip to main content
Participant
April 9, 2009
Answered

Play/Pause button

  • April 9, 2009
  • 1 reply
  • 1811 views

I am using Flash CS3 and ActionScript 2.0.

I have a flash timeline that shows 4 tabs and cycles through them. There is also a play/pause button. My issue is that when you click one of the tabs, you start the timeline up again, but the play/pause button doesn't reset.

A look at the attached should help. I have the full Flash file, as well, if needed.
http://www.danspeziale.com/flash/TabbedFlash10.swf

http://www.danspeziale.com/flash/TabbedFlash10.fla

I appreciate the help!
Dan

This topic has been closed for replies.
Correct answer Ned Murphy

Hi Ned,

I appreciate your answer. I don't have direct experience with this type of code. Is there anyone that can point me to an actual working example or code? Thanks again for the prompt response.

Dan


Here's a chance to get some experience then... That code is just short of being an actual working example that you can copy/paste in.

If you don't already have one, create an actions layer that extends the full length of your timeline and copy the playOn function in the first frame of it.  In that same frame, add...

var playActive = true; // this assumes the things starts in the play mode

Then, in each frame where you put a stop (relative to Dan's suggestion), replace it with the rest of the code I provided (the stop(); and the if(){setTimeout} bit ).

Then, for whatever code you already have for your play and pause buttons, add...

playActive = false;  // in the pause button code

playActive = true;   // in the play button code

If you have any wonderings about the code, the Flash help documentation is a good reference.  But feel free to ask if you can't find it or understand it.

1 reply

April 9, 2009

Hi Dan,

Put a stop(); on each of your keyframes where you have a tab.  That should do it.

dspezialeAuthor
Participant
April 9, 2009

Dan, thanks for the help. Unfortunately, now when "play" is pressed, it goes to the next tab and stops. I would like it to spend 6 seconds (or so) on each tab, then go to the next one. However if pause is pressed, I'd like it to work as normal tabs, without cycling through.

Thank you,

Dan

Ned Murphy
Legend
April 9, 2009

You'll probably need more logic built into the file to manage the options.  If the Pause button has been used, it could set a boolean variable (ex: playActive = false  Then, have the Play button set it to be true.  So when you get to each frame, you could have a conditional that utilizes this variable to see if it should wait awhile before proceeding (Play) or stay stopped (Pause).  You could use setTimeout for the delay.  So for each frame where you might currently have the stop();...

stop();

if(playActive){

   setTimeout(playOn, 6000);

}

and you could have a shared function for the timeout function call...

function playOn(){

   play();

}