View Full Version : A button that is a pause and play at the same time.
marksquall
04-01-2006, 10:24 AM
Hello to all Flash programmers,
A pleasant day to everyone. I just want to know how could I make a button that could act as a play and pause button at the same time, just like we see in most of Media Player (if we press the paly button, the play symbol changed into pause and vice versa). I used the button library in Flash MX (i.e. Circle Button).
I have 100 frames with two layers each, one layer is where my simple text animation is, and the second layer is my button.
I hope some one could help me about this.
Thank You and more power to all!
Regards,
Mark Squall
devilmaycry
04-01-2006, 11:32 AM
hi in a new layer name it script
and past this code
var paused=false;
_btn.onRelease=function(){
if(!paused){
_root.stop()}
else{
_root.play();
}
paused=!paused
}
marksquall
04-01-2006, 11:59 AM
Thank Sir for that code. Well Is there a way to swap button? Because I'm using two differnet buttons (The one I've got from Falsh library, i.e. a gel button), it really looks awfully bad to see a player with a play and pause button separate with each other...Is there something I could do to make the other button "invisible" if for example, I press the play button, then the play button will be "hidden" form the user's view then the pause button will appear, having the illusion that they are the "same button"
More power to you and all!
Regards,
MarkSquall
devilmaycry
04-01-2006, 05:59 PM
yes this is how
pause_btn._visible=false
play_btn.onRelease=function(){
_root.play();
pause_btn._visible=true
this._visible=false;
}
pause_btn.onRelease=function(){
_root.stop();
play_btn._visible=true
this._visible=false;
}
marksquall
04-02-2006, 07:17 AM
Dear Sir,
Are those codes located on the button (i.e Action - Button) or it should be placed in another layer (i.e Action - Layer)? my name of my play button is gelRight and the pause button is gelPause (it's the name of the button in the library so I didn't rename it though.
Thank you for your kind consideration. God bless.
Regards,
MarkSquall
oldnewbie
04-02-2006, 07:33 AM
Devil's code should be on a frame action, not on the buttons themselves... Make sure the buttons are present on stage on the frame you set the actionscript, and that they have the exact same instances names on stage as in the script.
The Library names aren't enough, they need to have instance names.
marksquall
04-02-2006, 08:19 AM
I just want to thank you Mr. DevilMayCry and Mr. Oldnewbie for the information. Now all I have to do is to put both buttons in the same x & y coordinate so that they seem look the same button, but behind the code, they are just two buttons "swapping" one after the another.
Hope to hear more from you! I really enjoy this forum! Thank you too to all viewers of those who take time in reading this issue.
Respectfully Yours,
Mark Squall
vBulletin® v3.7.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.