Eight buttons in Flash Animation

Source: Internet
Author: User

In the video editing control set, there is an on command that is closely related to flash. This command is specially designed for buttons. It provides eight types of Button events. They are press, slide, release, slide, external release, drag, drag, and button. The last is to define Keyboard Events. These eight kinds of time are often used in our daily production. Each time has different effects. Let's take a look at these cases.

Procedure

First, create a simple motion gradient animation. To intuitively describe the button function, we add the as: Stop (): In the 1st frame ():..

 

 

Make a simple animation

Create a button for a new layer, or click [Window] | [other panel] | [public database] | [button] to open the public database button panel, select a button from it and drag it to the 1st frame of Layer 2 ..

 

 

Drag the button to the stage

Finally, it is very important to open the as panel in the selected button state. Double-click the on command in global variables | video editing control. This command is automatically added to the input column on the right. 3.2.54.

 

 

On action command

Next we will introduce in detail the use of these eight events.

1. PressWhen the mouse pointer goes through the button, press the mouse button. Click press, select the Action Statement, and double-click the play command in global functions | timeline control.

The complete action is:

On (Press) {// set the mouse event to press, and then execute the statement in braces.
Play (); // execute the play (play) action after the button responds
}

.

 

 

Press action

Of course, you can also use other statements in braces, such as gotoandplay (yourframe); // click the button to play the video from the frame you set.

2. ReleaseRelease the mouse button when the mouse pointer goes through the button. Click Select release and add the play command as the first event. The completed statement is as follows:

On (release) {// when you press the mouse to release, execute the following statement action.
Play (); // execute the play (play) action after the button responds.
}

.

 

 

Release action

You can see that when the left mouse button is pressed, the playing action is not triggered, but when the left mouse button is opened, the playing action is executed. This is also different from the "Press" event.

3. releaseoutsideWhen the mouse pointer is within the button, after you press the button, move the mouse pointer out of the button, then release the mouse button. The method for adding statements is the same as that for adding statements. The complete statement is as follows:

On (releaseoutside) {// execute the following statement when the cursor is released outside the button.
Play (); // play after the button responds.
}

.

 

 

Releaseoutside action

Through this example, we know that the button action is triggered when the left mouse button is held down and moved outside of the button. This is a very imaginative event. You can use the on event to create a game.

4. roloutThe mouse pointer slides out of the button area. The production method is the same as above. The complete as statement is:

On (rolover) {// perform the following action when the mouse slides over the button.
Play (); // click the button to play the video.
}

.

 

 

Rolover action

When the mouse pointer slides over the button, the animation starts to play, instead of clicking it. We can use this feature of on to make some graphic panels, which is very simple and effective.

5. roloverMove the mouse pointer over the button. The production method is the same as above. The complete as statement is:

On (rolout) {// when you move the mouse over the button and leave, perform the following action.
Play (): // The button responds to the playback action.
}

.

 

 

Rolout action

Slide is not the same as slide. Slide refers to moving the mouse over the button and starting to respond after it leaves. Slide refers to starting the action as long as the mouse slides over the button.

6. dragoutWhen the mouse pointer slides over the button, press the mouse button and then slide out of the button area. The complete as is:

On (drag out) {// execute the following action when the mouse is dragged.
Play (); // execute the playback action.
}

.

 

 

Dragover action

The drag effect is to click and hold the mouse, remove from the button area, and then move back to the event released on the button. Note: In this example, a text button is used. When making a text button, a transparent square should be used below the text to add the response area of the button, or draw a rectangle at the 4th frame of the button to increase the display area.

7. dragoverWhen the mouse pointer slides over the button, press the mouse button, then slide this button, and then slide back this button. The complete as is:

On (dragout) {// execute the following action when the mouse moves away from the button.
Play (); // execute the playback action
}

.

 

 

Dragout action

Drag is different from drag. You only need to hold the left mouse button on the button and move it out of the button. The difference between the slide and the drag is that you need to hold down the left mouse button.

8. keypress ("key ")Press the specified key. For the key part of this parameter, you must specify the keyCodeOr a key constant.

In ("key"), type "K ". The complete as statement is:

On (keypress "Z") {// perform the following actions when you press "Z" on the keyboard.
Play (); // execute the playback action
}

.

 

 

Keypress action

Note: When adding a button to an animated file, you should place it on a separate layer to facilitate modification.

Show -- On is the action on the button. Therefore, you must select the button before you can add the on statement. Some friends asked in the Forum, "why is my on gray unavailable ?" The reason is that you have not selected the button.

Skill: In general Flash files, you will not intentionally distinguish these on functions. Generally, the default statement is used. If there are no special instructions, you can use the drag, slide, and other events to make the "replay" button, which will make people confused.

Try it -- we have learned so much about the features of on that we can use these features to easily create flash courseware and the effects in Flash games. You may wish to give it a try.

Analysis-the function of the on statement is closely related to the button. Where there is a button, the on statement must be used. When flash works exist, buttons appear. Therefore, the important role of on cannot be ignored. Today, we have introduced in detail various functions of on, so that we can combine the features of buttons to give full play to their functions.

Note

Button is an indispensable part of a complete FLASH file, so we also need to make it carefully.

Note

This section seems to have a lot of content, but the knowledge is easier to grasp. For example, release and slide are usually used in the eight events on, while other events are used less frequently. However, if we make courseware or game files, we will still use them.
We have already discussed the text button issue in the previous section. Be sure to pay attention to the text button area.

Related Questions

◎ How to create a button that is never touched?

We use the slide event in the on statement and the GOTO statement to achieve this effect. Let's create a button and drag it to the home scene. Copy four frames and change the button positions in 2nd frames, 3rd pins, 4th frames, and 5th frames. Return to 1st frames and add stop to the frame to stop the animation at 1st frames.

Add as: On (rolover) {// to the 1st frame button and execute the following action when the mouse passes.
Gotoandstop (2); // go to and stop at 2nd frames.
}
Add the as: On (rolover ){
Gotoandstop (3 );
}
Add the as: On (rolover ){
Gotoandstop (4 );
}
Add the as: On (rolover ){
Gotoandstop (5 );
}
Add the as: On (rolover ){
Gotoandstop (1 );
}

In this way, we have formed a loop in these five frames and jumped in sequence, so you will never be able to click this button.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.