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.
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(); } }
playBtn._visible = false;
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)
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?
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.
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
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; }
my bad: stop button: on(release){ stop(); stopBtn._visible=0; playBtn._visible=1; } play button: on(release){ play(); playBtn._visible=0; stopBtn._visible=1;
Excellent man your a legend that works nicely
actually one other thing.
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(); }
Don't see what you're looking for? Try a search.
|