Button | beginners | tutorial
Animation Demo:
Click here to download the source file
Well, we made a button today that has the as code. Main as (do not copy the following code, or you will get an error):
Movieclip.gotoandplay (frame)
Make a movie clip play to which frame.
Movieclip.gotoandstop (frame)
Make a movie clip stop to which frame.
On (MouseEvent) {
Statement
}
This means: MouseEvent can have the following functions:
Press down
Release press and let go
Rollover move into button area
RollOut move out of button area
DragOver Button Area
Dragout Drag out button area
KeyPress "button" Press a key (I do not recommend)
Okay, not much, we'll create a new document and click "Insert" to create a new component:
Well, click on "Library", double-click the button btn just edited, and here is its 3 frames:
Drag the button btn into the main scene, click it, open the Action panel, and enter the following code:
On (release) {
_root.sshow.gotoandplay (2);
}
_root refers to the main scene, sshow refers to the movie clip, gotoAndPlay (2), which refers to playing to the second frame.
Create a new movie clip with the name Sho, right click on the second frame of the timeline, insert a blank keyframe, and draw a small ball:
Well, ah. Insert a keyframe at the 15th frame of the time, point to frame 15th, point to the drawn ball, click on the "Freeform tool", and then point to a point on the ball, hold down the "SHIFT" Zoom, then click on the "Modify" menu, click "Align", click "Vertically Centered", then click the "Modify" menu, click "Align", click " Horizontal Center ", OK, now frame 15th is like this:
Well, click at 15 to 2 frames, open the Properties panel, and create a shape tween. As part, well, click on frame 15th, open the Actions panel and write code:
gotoAndStop (1);
Stop to the first frame. Well, click on frame 1th to open the Actions panel and write the code:
Stop ();
Back to the main scene, put it in, click on it, open the Properties panel, its "instance name" to "Sshow" test it!