
In this tutorial it will be analized how can be controlled the playhead of a MovieClip using ActionScript play() and stop() methods.
Rename the layers actions, movie, button starting from the top (like in the picture below).

In the first frame of the movie layer use the Oval Tool (O) from the Tools Panel to draw a circle about 40pxx40px (hold Shift key pressed to draw a perfect circle). Select none for Stroke Color and what do you wish for Fill Color.
Select the circle and choose Modify >> Convert to Symbol (F8). In the Convert to Symbol window that appear choose MovieClip as Type, give it a name of ballMC and choose also center for Registration point like in the following image:

Now right-click on the ball_mc and choose Edit in Place or double-click it. You are in the Edit Mode for ballMC now.
![]()
Select the ball and choose again Modify >> Convert to Symbol (F8). In the Convert to Symbol window choose same options like above and give it a name of ball2MC.
Go to in the first frame of the Layer1 and in the Properties panel choose Tween:Motion. Go to the frame 30 and right-click >> Insert Keyframe (F6). Go to the frame 60 too and repeat the step.
Go back to frame 30 and change the position on the ball whetever you wish, but having at least 100 pixels from the original position.
Now click Scene 1. Go to the first frame of the button layer. Go to Window >> Common Libraries >> Buttons. Choose from here a what button you desire and drag it on the Stage. In the Properties panel give it an instance name of button_btn.

Now go to the first frame of the actios layer. Open the Actions panel (F9) and put this ActionScript code in:
var contor:Number=0;
// we use the contor variable to hold the state of the ball: 1 if it is stopped, 0 if the ball is playing
button_btn.onRelease=function(){
if (contor==1){
ball_mc.play(); contor=0;
// if the ball MovieClip is stopped we use the play() method to make it move
}
else if (contor==0){
ball_mc.stop();
contor=1;
}
}
// if the ball MovieClip is playing we use the stop() method to stop it
RSS feed for comments on this post · TrackBack URI
Leave a reply