Skip to main content
Inspiring
Mar 15, 2024 2:32 PM UTC
Answered

PlayPause song in the same button in adobe animate?

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.
    kglad
    kgladCorrect answer
    Community Expert
    Mar 15, 2024 2:36 PM UTC

    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
    Mar 15, 2024 2:36 PM UTC

    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

    }

    Translate
    Inspiring
    Mar 15, 2024 2:45 PM UTC

    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

     

    Translate
    kglad
    Community Expert
    Community Expert
    Mar 15, 2024 2:47 PM UTC

    good to hear!

    Translate