Skip to main content
Known Participant
January 13, 2010
Answered

Help with button code please?

  • January 13, 2010
  • 1 reply
  • 603 views

I am a novice and have just completed my first animated movie. I need help with action script.

The movie is currently looped and I have created and invisible button the size of the frame with the intention that a user can click on the movie image to stop it and on second click continue the movie from where it stopped.

I have used the AS event handler method to stop the movie. I have tested it and it works. But I cannot figure suitable code to restart the movie.

Two questions;

1. am I going about the task the right way? (should I use two buttons, one stop, one start)?

2. if my approach is feasible, can anyone give me the correct AS to re-start the movie and put me out of my misery please?

This topic has been closed for replies.
Correct answer kglad

you can use the following after changing "yourbutton" and "yourmovieclip" to use suitable instance names:

yourbutton.onRelease=function(){

if(!this.toggle){

yourmovieclip.stop();

} else {

yourmovieclip.play();

}

this.toggle=!this.toggle;

}

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
January 13, 2010

you can use the following after changing "yourbutton" and "yourmovieclip" to use suitable instance names:

yourbutton.onRelease=function(){

if(!this.toggle){

yourmovieclip.stop();

} else {

yourmovieclip.play();

}

this.toggle=!this.toggle;

}

Known Participant
January 14, 2010

Dear kglad.com,

Sir, you are a scholar and a gentleman. Your AS script worked first time.

Many thanks for your swift reply.

kglad
Community Expert
Community Expert
January 14, 2010

you're welcome.