Skip to main content
Inspiring
March 15, 2024
Answered

PlayPause song in the same button in adobe animate?

  • March 15, 2024
  • 3 replies
  • 301 views

hello there 

i want to make a play/pause button

the same button for two functions

i am using this code...

 

import flash.events.MouseEvent;

stop();

start_button.addEventListener (MouseEvent.CLICK, onClick);

function onClick(event:MouseEvent):void

{

nextFrame(); // if you want to go to frame 2 and stop

play(); // if you want to go to frame 2 and play

}

 

it works for playing but not for pausing........

whats the action script for playpause in the same button?

anybody help me

 

    This topic is closed to new replies. Start a new post to keep the conversation going.
    Correct answer kglad

    import flash.events.MouseEvent;

    stop();

    var toggle:Boolean

    start_button.addEventListener (MouseEvent.CLICK, onClick);

    function onClick(event:MouseEvent):void

    {

    if(toggle){

    nextFrame(); // if you want to go to nextframe and stop

    } else {

    play(); // if you want to go to nextframe and play

    }

    toggle=!toggle;  // or place this as first line of onClick, if you want to change how the button starts

    }

    3 replies

    kglad
    Community Expert
    kgladCommunity ExpertCorrect answer
    Community Expert
    March 15, 2024

    import flash.events.MouseEvent;

    stop();

    var toggle:Boolean

    start_button.addEventListener (MouseEvent.CLICK, onClick);

    function onClick(event:MouseEvent):void

    {

    if(toggle){

    nextFrame(); // if you want to go to nextframe and stop

    } else {

    play(); // if you want to go to nextframe and play

    }

    toggle=!toggle;  // or place this as first line of onClick, if you want to change how the button starts

    }

    Inspiring
    March 15, 2024

    hello man it worked

    thank you a lot

    i ll mark as correct

    finished this issue

    i post another issue separate

    in order to maintain your answer

     

    kglad
    Community Expert
    Community Expert
    March 15, 2024

    good to hear!