Skip to main content
July 12, 2010
Answered

How to set criteria to Play/Pause buttons

  • July 12, 2010
  • 1 reply
  • 300 views

How to set conditional criteria to Play/Pause buttons?

i.e. to pause the animation only if the animation is playing; and to  play the animation again only if the animation is paused. thanks.

on(release) {
play();
}

on(release) {
stop();
}
This topic has been closed for replies.
Correct answer Ned Murphy

Here's where that isStopped variable you had in your other posting could be handy if the intention is to have one button do both...

var isStopped:Boolean  = false; // assuming it is playing at the start

on(release){

     if(isStopped){

          isStopped = false;

          play();

     } else {

          isStopped = true;

          stop();

     }

}

But if you have separate buttons for Play and Pause, what you showed already would be sufficient when you match the two code bits to the correct buttons.

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
July 12, 2010

Here's where that isStopped variable you had in your other posting could be handy if the intention is to have one button do both...

var isStopped:Boolean  = false; // assuming it is playing at the start

on(release){

     if(isStopped){

          isStopped = false;

          play();

     } else {

          isStopped = true;

          stop();

     }

}

But if you have separate buttons for Play and Pause, what you showed already would be sufficient when you match the two code bits to the correct buttons.