Play pause toggle button

Hi,
I'm new to Flash. Kindly help anyone.
Need assistance to create toggle button. Here attaced two screenshots.
1. inner-animation.jpg - it contains all movie clips and play pasue controls.
2.main-animation.jpg - this is the main timeline ( inside all movie clips & control buttons)
3.playbuton-inside.jpg - its a button symbol ( as well as pause )
4. There also bg music and sounds for some particular animation.
Here all working fine. But i need play & pause animation as a toggle button.
Here is the code i added for pause:
play();
pause_btn.onRelease=function(){
stop();
Here is the code i added for pause:
stop();
play_btn.onRelease=function (){
play();

You are using AS2 code, so you should be posting in the AS2 forum (http://forums.adobe.com/community/flash/flash_actionscript?view=discussions).  If the intention is to use AS3 code, then you need to change things.
If the intention is to use the same single button for both pause and play, then what you normally would do is establish a boolean variable that you se to determine whether the clicking of the button should play or stop the movie...
var playMovie:Boolean = true; // assumes the movie is stopped at the start
pause_play_btn.onRelease = function (){
   if(playMovie){
       play();
       // manage play/pause btn
   } else {
       stop();
       // manage play/pause btn
   playMovie = !playMovie; // reverse the value of the playMovie variable
In that code where I show "// manage play/pause btn" is where you need to do whatever you need to make the pause/play button appear as intended... either hiding one or the other, or changing its frames to show the appropriate image.

Similar Messages

  • How best to handle a start button and a play-pause toggle button?

    Hello,
    Still new to AS3, on a project for a client. I'd appreciate advice on how best to handle the navigation for 5 movieclips set inside 5 separate frames on the main timeline. I have a play button on frame 1 to start the animation, but I'd like to include a play/pause toggle button on the other frames to finish the navigation. Everything works except the toggle button, when clicked, does toggle but does not stop the animation. I've copied the code, including the toggle button code on frame 4 below. How best to handle both a start button and a play-pause toggle button?
    Thanks for any help in advance.
    Frame 1:
    PlayBtn_mc.buttonMode = true;
    stop();
    PlayBtn_mc.addEventListener(MouseEvent.CLICK,startMovie);
    function startMovie(event:MouseEvent) {
    gotoAndPlay(2);
    Frame 2:
    stop();
    Frame 3:
    stop();
    Frame 4:
    RewindBtn_mc.buttonMode = true;
    RewindBtn_mc.addEventListener(MouseEvent.CLICK,rewind);
    function rewind(e:MouseEvent) {
    prevFrame();
    FFBtn_mc.buttonMode = true;
    FFBtn_mc.addEventListener(MouseEvent.CLICK,forward);
    function forward(e:MouseEvent) {
    nextFrame();
    ToggleBtn_mc.buttonMode = true;
    ToggleBtn_mc.addEventListener(MouseEvent.CLICK, doToggle);
    function doToggle(myevent:MouseEvent):void {
    ToggleBtn_mc.play();
    Frame 5:
    (Loops back to Frame 1)

    I can't tell you how appreciative I am of all your assistance.
    Could you double-check on this, I may have stumbled upon somthing- I tweaked your last code, which toggled, but didn't seem to call the scene_test_mc into action.
    But I copied below what both toggles the play/pause button and calls the mc into action. Could you verify this as reliable code and not a fluke that will break? Thank you so much! :
    ToggleBtn_mc.buttonMode = true;
    ToggleBtn_mc.addEventListener(MouseEvent.CLICK, doToggle);
    scene_test_mc.buttonMode=true;
    scene_test_mc.addEventListener(MouseEvent.CLICK, doToggle);
    function doToggle(myevent:MouseEvent):void {
    var mc:MovieClip=MovieClip(myevent.currentTarget);
    if(mc.currentFrame==1){
    mc.gotoAndStop(2);
    scene_test_mc.play();
    } else {
    mc.gotoAndStop(1);
    scene_test_mc.stop();

  • Animation couldnt control with Play pause toggle button..

    I have multiple movie clip with bg sound.I have used the code AS3 for toggling the animation ( Play & Pause ).Automatically the animation starts and button also togggled on click but couldnt control the animation .
    I need some solutions like when the intial stage the animation wont start etither the button click to play.After that the flow as it is in action ( ON Click ). Kindly anyone guide me to solve it. i'm very new to flash. this is my first project and ihave to finish it soon..
    btns.visible = false;
    btns.addEventListener(MouseEvent.CLICK,onEl);
    dfr.addEventListener(MouseEvent.MOUSE_OVER,onEls);
    dfr.addEventListener(MouseEvent.MOUSE_OUT,onEld);
    btns.addEventListener(MouseEvent.MOUSE_OVER,onEls);
    btns.addEventListener(MouseEvent.MOUSE_OUT,onEld);
    var _vrSts:int = 0;
    function onEl(eve:Event):void    {
        if(_vrSts)    {
            trace('status:'+_vrSts);
            _vrSts = 0;
            btns.gotoAndPlay(1);
        }else    {
            trace('status:'+_vrSts);
            _vrSts = 1;
            btns.gotoAndStop(2);
    function onEls(eve:Event):void    {
        btns.visible = true;
    function onEld(eve:Event):void    {
        btns.visible = false;

    Hi Ned!
    i done it. here is the solution.One issuse is" End of the animation it goes to 1st frame with pause button, but intially there has play button."
    stop();
    btns.visible = true;
    btns.addEventListener(MouseEvent.CLICK,onEl);
    dfr.addEventListener(MouseEvent.MOUSE_OVER,onEls);
    dfr.addEventListener(MouseEvent.MOUSE_OUT,onEld);
    btns.addEventListener(MouseEvent.MOUSE_OVER,onEls);
    btns.addEventListener(MouseEvent.MOUSE_OUT,onEld);
    var _vrSts:int = 0;
    function onEl(eve:Event):void    {
        if(_vrSts)    {
            //trace('status:'+_vrSts);  
            _vrSts = 0;
            //btns.label = "Play";
            btns.gotoAndPlay(1);
            btns.visible = false;
            //if(currentFrame == 445)
                //gotoAndPlay(1);
                if(currentFrame == 445) {
                gotoAndPlay(1);    
                btns.gotoAndStop(1);    
            else
               stop();
            //btns.gotoAndStop(1);
        }else    {
            //trace('status:'+_vrSts);
            //stop();
            _vrSts = 1;
            btns.gotoAndStop(2);
            //btns.label = "Pause";
               play();
    function onEls(eve:Event):void    {
        btns.visible = true;
    function onEld(eve:Event):void    {
        if(_vrSts)
            btns.visible = false;

  • Play/pause toggle help pls

    Hello! I need a little help getting a toggle button to work properly.
    I have the following code for a custom btn to play/pause toggle a video I have loaded. The only thing is that its not working... I can get it to play and pause but I cant get it to resume playing. It just keeps being paused even after I press the playBtn.
    public function playPauseVideo (event:Mouse):void {
          if (player.playing) {
              player.pause();
              removeChild(pauseBtn);
              addChild(playBtn);
              playBtn.x = (stage.stageWidth) /2;
              playBtn.y = 930;
          }else{
              player.play("video.f4v", 60, false);
              removeChild(playBtn);
              addChild(pauseBtn);
              pauseBtn.x = (stage.stageWidth) /2;
              puaseBtn.y = 930;
          playBtn.addEventListener(MouseEvent.CLICK, playPauseVideo);
          pauseBtn.addEventListener(MouseEvent.CLICK, playPauseVideo);
    Can u pls give me a hand?
    Thanks for any help!

    Good points. Thanks!
    So I have reduced the code down to this:
    public function playPauseVideo (event:MouseEvent):void {
          if (player.playing) {
              player.pause();
              playBtn.alpha = 100;
              pauseBtn.alpha= 0;
          }else{
              player.play("video.f4v", 60, false);
              pauseBtn.alpha = 100;
              playBtn.alpha = 0;
    I have code earlier than this which sets the buttons on the stage and adds the listeners so its only created once. Thanks for that point out.
    Now this is what happens: I when I publish, I click the playBtn and the video plays, the playBtn disappears and the pauseBtn appears. Then I click the pauseBtn and the video pauses, and pauseBtn disappears and the playBtn appears. I click the playBtn and then nothing happens - except the playBtn disappears and the pauseBtn appears - but the video does not play.
    Any ideas?
    Thanks for the help!

  • Play/Pause/Power button toast. Warranty expires soon.

    Over the past couple months the play/pause/power button has been getting more and more hard to use. my warranty is up in about a week and im sure the warranty would not cover this. i don't press the button hard at all. it just started a couple months ago if that.
    what do i do?
    6G 80GB

    Hi, Sheogorath. When did you purchase it? Have you tried sending it to the Care Point for evaluation? You may check this link to locate the nearest one in your area: http://www.microsoft.com/en/mobile/locale/. 

  • New Aluminium Keyboard Vol/play/pause etc buttons wont work

    Hello everyone, thank you for your time.
    I'm screaming at my new keyboard, I bought another Apple Aluminium Wireless keyboard to replace my previous one from 2007 that essentially went nuts after the last update.....I couldnt use the up and down arrows, the shift key would "hold itself down" etc.
    This new one wont let me use its play/pause, volume mute, down, and up etc buttons....I've remapped several Expose functions and Dashboard to work right, but you cant do anything for the audio control buttons....?
    This is too much for me, I'm very angry at this odd problem. It seems SO simple, it should just work like my previous keyboard did....
    I cant handle not having control of my iTunes music.... I could keep BOTH my Apple keyboards on and use one for play pause etc, and the other for everything else.....
    I have a hint for what the problem might be, it seems this keyboard shows up as the "old" "fat white and clear plastic wireless keyboard", perhaps that keyboard didnt have the same functions as the Aluminium? When it disconnects from my Mac for example, I dont get correct "aluminium keyboard connection lost" side on icon, I get one of the larger older plastic keyboard....
    I think this is the problem, that this keyboard identifies as the very old plastic model.....
    Im going nuts over this very simple function of a keyboard....my last keyboard blew up after the update....ok, so I have to shell out another $120 NZD for a new keyboard...ok....I'm an Apple fan, I'll choke on my pride, and when it finally arrives, from Australia....it wont control iTunes like I do several times a day....
    Can anyone help me? I tried using the firmware updates but it seems like it didnt even identify the keyboard...it showed nothing in the detection box....the keyboard was paired, probably showing up as another model of keyboard.....
    Very annoying!
    Thank you very much for your help. I hope you have a great day.

    alright its not doing it anymore after a restart. I think it was from plugging in a Logitech wireless mouse keyboard combo but i didn't use the keyboard so i didnt calibrate it. Sorry for the useless post.
    Message was edited by: NeoTranc3

  • Play/pause mouse button no longer works since update?

    I have a mouse with several buttons, one of which I customized to be "Play/Pause". This was great for iTunes -- if I was in Firefox or something, I could click it and immediately play/pause the song.
    However, with the new version of iTunes, this button no longer works, neither outside of iTunes nor inside. The button still works with other programs that it used to (eg, VLC), so it's specific to iTunes.
    My hopes aren't high, but is there any chance of solving this?

    Hi, Piafromvic. This forum is about using apple's new iBooks Author software to create books. There's a separate forum for help with the ibooks app for reading books and you might get more answers there:
    https://discussions.apple.com/community/app_store/ibooks
    Good luck!

  • Using default CS5 skin, play/pause & stop buttons disabled until going fullscreen

    We are using default CS5 skins with an flvplayback component built through action script 3.  When playing certain videos (and only certain videos, however there isn't yet a pattern), the play/pause, stop & seek buttons are completely unresponsive.  They don't change stats on hover & they are unclickable.
    However, the fullscreen button does always work, and upon going fullscreen and coming back out, the buttons now work again.
    I really have no idea what is going on here, it seems rather random.  So far, the problem was seemingly at its worst displaying a video that was encoded with Sorenson spark (an older codec) and we wondered if it had to do with the file itself, the headers, anything of that sort.  But the fact that the skin and buttons work fine once entering and exiting fullscreen - that is perplexing.

    Just an update, but the following line:
    my_FLVPlybk.scaleMode = "noScale";
    Has something to do with the issue.  When we include this line (which tells the player to resize to the size of the given FLV), we get the problem with the buttons not working.  If we take the line out, we do not see that problem.

  • A problem with the Play/ Pause control button in a quiz project

    Hi,
    I have a probem with the play/ pause button in this project,
    it is a quiz project, the problem is when I click the pause the
    project does not pause and keep working ? Any idea why?
    http://www.megaupload.com/?d=995I8WX9
    Thanks

    If you have bought you Macbook within 90 days or have bought AppleCare you can call them for free and ask them what you should do. 1-800-MY-APPLE

  • Is it possible to change the link to the WMP of the Play/Pause/Stop buttons

    Is it possible to change the link to the WMP of the Play/Pause and Stop Button?
    Because by software only the Network and Media Buttons are changable.
    And I don't prefer WMP to be my favorite media player.

    I used to have this problem too. When pressing +play/pause+ button on my +Satellite+ always wmp start. I used RM-X media to configure media keys, or Global Hotkeys in Winamp to solve this problem, but in case of +play/pause+ it was still the same. I found simple solution how to use this key in Winamp - assaying Winamp as default media player in Control panel/Add remove programs. And then in specific application edit file associations.

  • Play/pause Toggle Problem

    My custom-built Flash player is experiencing a problem with
    the pause/play function. After pausing a video and then toggling
    back to play mode, the video "rewinds" about 1-2 seconds from where
    it was paused and then starts playback. How do I force it to start
    playing again from the frame it was paused on, instead of
    rewinding? This is happening on a Win XP system running IE version
    7.0.5xxx and Flash version 9.0.16.0.
    Thanks/Leo

    Thanks for sharing your blog. I actually did whatever you explained in your blog. I created advance actions. I labeled the buttons, btn_Play, btn_Pause, respectively. And, in "Play" advance action, I added the following command "Show -> btn_Pause", "Hide -> btn_Play", and vice versa for "Pause" advance action. It is working, but irregularly.
    As the example in your blog, If I test it in the single slide, it is working great. However, if I do consequetive transitions to other slides fastly, it sometimes stops working (for example, when I click "Play" button, the "play" button does not disappear, and "pause" button does not show up). I know this sounds so weird!
    Also, another point is that I did not use master slide, I just put them in the first slide, and set them visible for the rest of the project. I see that you did not recommend this practice.

  • Using REW/Play/Pause/FF buttons in VLC Possible?

    Hello, just wondering if there's a way to make the new control buttons on the Air work in VLC like they do in QT/iTunes et al.?
    Thanks in advance!

    According to VLC Devs, this is currently not possible, but MAY be added into 0.9 if the keycodes for the Air's multimedia buttons can be decoded.

  • Controlling keybaord Play/Pause button

    Hello:
    I have a PS2 keyboard that I cannot find a good replacemnt for, so I will keep it (Windows Natural Multimedia Keyboard). Most multimedia buttons on it works, but not Play/Pause, which I would really need. Spacebar works as a Play/Pause toggle, but only if the iTunes window is visible on the monitor screen. (Play/Pause would probably work on a USB keyboard, but, as I said, I cannot find anything but black keyboards, and my eyes are saying "No!".)
    Now, I can program buttons, and I wonder if there is any way to control iTunes Play/Pause via some command or such?
    Grateful for tips.
    Regards,
    Hans L

    Costco has an awesome return policy -
    90 days
    opened box,
    full refund..
    and they dont check serial #s)
    (Honestly i have no idea why Apple allows their iPods to be sold under so lenient a returns policy)
    Anyway, this info is facts. Do with it what you will.

  • MP3 Player Play/Pause?

    I'm making an MP3 player.  I can't get the play/pause toggle to work.  I'm not sure how to have the event be toggled on and off. Sorry, I'm a newbie to flex.
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:net="flash.net.*" xmlns:media="flash.media.*" creationComplete="mySound.load(myURLReq)" themeColor="#000000" borderColor="#000000" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#FFFFFF, #FFFFFF]">
        <mx:Script>
            <![CDATA[
                private function appInit():void {
                    stage.addEventListener( KeyboardEvent.KEY_DOWN, keyPressHandler );
                private function keyPressHandler( e:KeyboardEvent ):void {
                    // if the spaceBar is pressed then toggle play/pause
                    if( e.charCode == 32 ) {
                        if( this.focusManager.getFocus() != toggleBtn ) {
                            this.focusManager.setFocus( toggleBtn );
                            // whatever happens when you click on the button you place here
                            // it's best to have a 'clickHandler' that calls another method
                            toggleBtnHandler();
                private function clickHandler( e:Event ):void {
                    toggleBtnHandler();
                private function toggleBtnHandler():void {
                    if( toggleBtn.label == "PLAY" ) {
                        toggleBtn.label = "PAUSE";
                    } else {
                        toggleBtn.label = "PLAY";
            ]]>
        </mx:Script>
    <mx:Button id="toggleBtn"
            x="10" y="70" toolTip="Press the spacebar to toggle label"
            click="clickHandler( event );"
            label="PLAY"/>
       <mx:Number id="myPos">0</mx:Number>
       <net:URLRequest id="myURLReq" url="01-amy_macdonald-dont_tell_me_that_its_over.mp3" />
       <media:SoundChannel id="mySoundChannel" />
       <media:Sound id="mySound" />
       <mx:Panel title="MP3 Player">
         <mx:Text id="prog" />
         <mx:ControlBar>
           <mx:Button id="play" label="PLAY" click="mySoundChannel = mySound.play(myPos, 0, null);" />
           <mx:Button id="pause" label="PAUSE" click="myPos = mySoundChannel.position; mySoundChannel.stop();" />
           <mx:Button id="stop" label="STOP" click="mySoundChannel.stop();" />
         </mx:ControlBar>
       </mx:Panel>
    </mx:Application>

    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=15&catid=288&threadid =1248142&highlight_key=y&keyword1=mp3
    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=15&catid=288&threadid =1249411&highlight_key=y&keyword1=mp3
    http://www.adobe.com/cfusion/webforums/forum/messageview.cfm?forumid=15&catid=288&threadid =1247499&highlight_key=y&keyword1=audio

  • How can i change the settings of play/pause in Elements 13?

    Hello!
    How can i change the settings of play/pause in Elements 13? I definitely need cursor back to the "start play" point each time i hit stop (spacebar), like it works in Sony Vegas or in most of audio editing software. Can somebody help?
    Thanks!

    invasion 21
    The following is a copy of the reply that I posted to your question earlier today in the Adobe Premiere Pro Forum
    invasion21
    You are in the Adobe Premiere Pro Forum. What is your program? Is that Premiere Elements 13? If so, you are in the wrong forum where
    Premiere Pro answers may not be appropriate for your Premiere Elements (any version) question.
    You are not going to find what you are looking for in Premiere Elements preference settings.
    You write
    I WANT it playhead jump back to start play position, when i hit spacebar for pause.
    You can maneuver yourself into that through Edit Menu/Keyboard Customization/Applications/ and its Help category which by
    default shows
    Go to Timeline/Clip Start, using Home
    and
    Play/Pause Toggle, using Space
    But, you may find it is best to leave well enough alone. Explore and experiment with changing the keyboard shortcuts for the commands and decide what works for you.
    ATR

Maybe you are looking for

  • Importing iPhoto `11 Library Lost Folders & Nested Albums

    Been using iPhoto since its' inception. Currently at iPhoto `11. Had created many Albums and Smart Albums based on Keywords and had most of them organized into Folders in iPhoto. Just bought Aperture 3 and, following the video tutorial provided by Ap

  • How to add new column to COPA datasource?

    Dear all, It seems we have to delete the COPA datasource and regenerate it when we need add new column, if so,we should regenerate the initialIzation for the delta. Beacause only the new delta data need have value for new column,so I do not want to r

  • XML formating help Please

    Hi Everyone, I'm new to XML and hoping someone can help me. XML seems pretty straightforward, so I'm not sure why I can't get my head around this. Here's what I need. I'm building a webpage in Dreamweaver using Spry that will have a list of all 50 U.

  • IWeb and fonty goodness

    hey everyone just wondering, if i use a certain font in iweb, does the user have to have that font installed locally for them to view the web page as i do in iweb with that font the default font seems to be palatino, but i've never seen this installe

  • I need to create private members pages for a site I am building

    Is it possible to make PRVATE PAGES that on only site members can see?