all groups > flash actionscript > may 2005 >
You're in the

flash actionscript

group:

play/pause button in interactive



play/pause button in interactive twistedpancreas
5/17/2005 12:00:00 AM
flash actionscript: Hi there,

got bits of this off actionscript.org, but have one question.

I have a set of buttons that allows the user to view segments of a movie; the
playhead travels until it hits the "stop" action. If the user hits button
number one, they see segment one of the movie, if they hit button number two
they see the second segment, etc.

I then have a "play all" all button with the code:

on(release) {
playAll = true;
play();
}

having changed each stop action to:

if(!playAll) stop();

What I want now is to be able to have the "play all" button turn to a "pause"
button and when clicked in the pause state, it halts the movie.

Can this be done?

Thanks in advance.
Re: play/pause button in interactive kglad
5/18/2005 12:00:00 AM
you can remove or disable all that frame script and make your playall button a
toggle that alternately plays and stops your movie:

on(release){
if(!paused){
paused=1;
stop();
} else {
paused=0;
play();
}
}
Re: play/pause button in interactive SMakinson
5/18/2005 12:00:00 AM
Re: play/pause button in interactive SMakinson
5/23/2005 12:00:00 AM
playBtn._visible = false;
Re: play/pause button in interactive twistedpancreas
5/23/2005 12:16:31 AM
ok thanks kglad that worked

but i'm a bit confused SMakinson on how to get 2 buttons to toggle off and on
in visibility

if u could help that would be great (since kglad's script works a treat on a
button)
Re: play/pause button in interactive kglad
5/23/2005 12:33:00 AM
Re: play/pause button in interactive twistedpancreas
5/24/2005 12:00:00 AM
ok i got some weird stuff happening now

on the play button i have:

on (release) {
if(!paused){
playBtn._visible = false;
paused=1;
stop();

} else {

playing
paused=0;
play();
}

fPlaying = !fPlaying;
sButtonText = this["sButtonText"+Number(fPlaying)];
}

and on the pause button i have

on (release) {
if(!paused){
playBtn._visible = true;
paused=1;
stop();

} else {

playing
paused=0;
play();
}

fPlaying = !fPlaying;
sButtonText = this["sButtonText"+Number(fPlaying)];
}

So when you start the swf, the pause button is visible.

When you click the play button it disappears, but when you click the pause
button it takes 2 clicks to reveal the play button, and the pause button
doesn't disappear.

Have I got this all screwed now?
Re: play/pause button in interactive kglad
5/24/2005 12:00:00 AM
if you want to different play and stop buttons that disappear when not needed
you can use:

attached to your play button ->

on(release){
play();
this._visible=0;
stopBtn._visible;
}

attached to your stop button ->

on(release){
stop();
this._visible=0;
playBtn._visible;
}

and attached to a frame to initialize:

playBtn._visible=0; // if your movie, by default, is playing at the start.
stopBtn._visible=0; // if your movie, by default, is stopped at the start.

p.s. this assumes your buttons have the above instance names.
Re: play/pause button in interactive twistedpancreas
5/24/2005 12:00:00 AM
ok i have a stop action at the start with your

stopBtn._visible=0;

I have the buttons named playBtn and stopBtn.

but playBtn disappears when clicked on, but stopBtn doesn't reveal

Re: play/pause button in interactive kglad
5/24/2005 12:00:00 AM
oops, my bad:

attached to your play button ->

on(release){
play();
this._visible=0;
stopBtn._visible=1;
}

attached to your stop button ->

on(release){
stop();
this._visible=0;
playBtn._visible=1;
}

Re: play/pause button in interactive twistedpancreas
5/24/2005 12:00:00 AM
Re: play/pause button in interactive twistedpancreas
5/24/2005 12:00:00 AM
Re: play/pause button in interactive kglad
5/24/2005 12:00:00 AM
Re: play/pause button in interactive kglad
5/24/2005 12:00:00 AM
Re: play/pause button in interactive twistedpancreas
5/27/2005 12:00:00 AM
Re: play/pause button in interactive kglad
5/27/2005 12:00:00 AM
my bad:

stop button:

on(release){
stop();
stopBtn._visible=0;
playBtn._visible=1;
}

play button:

on(release){
play();
playBtn._visible=0;
stopBtn._visible=1;
Re: play/pause button in interactive twistedpancreas
5/27/2005 12:00:00 AM
Excellent man

your a legend that works nicely

Re: play/pause button in interactive kglad
5/27/2005 12:00:00 AM
Re: play/pause button in interactive twistedpancreas
5/29/2005 10:55:14 PM
actually one other thing.

Re: play/pause button in interactive kglad
5/30/2005 12:00:00 AM
Re: play/pause button in interactive kglad
5/30/2005 12:10:17 AM
after the stop() has executed you can use _root.play() (assuming it's the _root
timeline that you want to play). if you want to code something so a stop()
which hasn't executed yet, doesn't execute, you'll need to use some kind of
conditional statement to prevent your stops from executing when a variable is
set by your play button.

for example:

playbtn.onPress=function(){
override=1;
}

and instead of a stop() in your frames use:

if(!override){
stop();
}
Re: play/pause button in interactive twistedpancreas
5/30/2005 2:01:20 AM
Re: play/pause button in interactive twistedpancreas
5/30/2005 2:01:50 AM
AddThis Social Bookmark Button