The difference between the eight actions that flash makes to the buttons applied to the animation

Source: Internet
Author: User
Tags functions
Button | difference

  What is the difference between eight actions in a button?

  Solving ideas

In the movie clip control collection There is also an on command that is closely related to our system of flash. This command is designed specifically for the button, which provides eight kinds of button events. They are pressed, slid over, released, slid away, externally released, dragged over, dragged away and pressed. The last one is the event that defines the keyboard. These eight kinds of time in our peacetime production often can use, each kind of time has the different effect, below we will combine the case to everybody analysis.

  Specific steps

First we make a simple moving gradient animation. To visually illustrate the function of the button, we add As:stop () in frame 1th:. As shown in the figure.

Make a simple animation

Then we create a new layer to make a button, or click "Window" | "Other Panel" | "Common Library" | "button" command, open the Common Library button panel, select a button from inside and drop to frame 1th of Layer 2. As shown in the figure.

Drag and Drop buttons to the stage

Finally, it is also very important that you have to open the as panel in the state of the selected button. Double-click the on command in global variables | Movie clip control to automatically add the command to the input bar on the right. As shown in Figure 3.2.54.

On action command

Here we will give you a detailed introduction to the use of these eight kinds of events.

1. Press the mouse button when the mouse pointer passes over the button. Click Press, and then select the Action statement and double-click the Play command in global function | Timeline control.

The complete action is:

On (Press) {//Set mouse events as pressed, and then execute the statements inside the curly braces.
Play (); Play (playback) action after a button response
}

As shown in the figure.


Press action

Of course, in the curly braces can also be used in other statements, such as gotoAndPlay (Yourframe); When you click the button, it will be played from the frame you set.

2. Release the mouse button when the mouse pointer passes over the button. Click to select Release and then join the play command as the first event. The completed statement is as follows:

On (release) {//When the mouse is down, execute the following statement action.
Play (); Performs play (playback) action after a button response.
}

As shown in the figure.


Release action

You can see, when the left mouse button pressed, and did not stimulate the playback action, but when the left mouse button release, the execution of the play action. This is also a different place from the "press" event.

3, releaseoutside when the mouse pointer in the button when the button, move the mouse pointer outside the button, the mouse button released at this time. The method of adding a statement is the same as. The complete statement is as follows:

On (releaseoutside) {///When the mouse is released outside the button, execute the following statement.
Play (); Performs a playback action after a button response.
}

As shown in the figure.

Releaseoutside Action

By this example we know that when the left mouse button is pressed and moved to a place other than the button, the button's action is triggered. This is a very imaginative event, and you can use on this event to make the game.

4. RollOut the mouse pointer out of the button area. The production method is as follows, the complete as statement is:

On (rollover) {////When the mouse slides onto the button, perform the following action.
Play (); button to perform the playback action.
}

As shown in the figure.

Rollover action

When the mouse pointer slips over the button, the animation starts playing, without having to click it. We can use on this feature to make some diagram board, very simple and effective.

5, rollover the mouse pointer over the button. The production method is as follows, the complete as statement is:

On (RollOut) {////When the mouse slides onto the button and leaves, perform the following action.
Play ()://button responds to playback action.
}

As shown in the figure.

Rollout action

Slipping is not the same as slipping, which is when the mouse slides onto the button and starts to respond after leaving, and the slide is when the mouse clicks on the button and begins to perform the action.

6, dragout the mouse pointer over the button when the mouse button, and then slide out of this button area. The complete as is:

On (Drag out) {///When the mouse is dragged, perform the following action.
Play (); Performs the playback action.
}

As shown in the figure.

DragOver Action

The effect is to click on the button and hold down the mouse, move out of the pressing area, and then move back to the released event on the button. Note: This example is a text button, when you make a text button, you should use a transparent box at the bottom of the text to increase the response area of the button, or draw a rectangle on the 4th frame of the button to increase the reflection area.

7, DragOver the mouse pointer over the button when the mouse button, and then slide out of this button, and then slide back to this button. The complete as is:

On (dragout) {////When the mouse is dragged away from the button, perform the following action.
Play (); Perform play action
}

As shown in the figure.

Dragout Action

Drag-and-drop is different, as long as you hold down the left mouse button and then move to the button will be appropriate. The difference between him and the slide 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 specify a keying code or key constant.

We type "K" in ("Key"). The full as statement is:

On (keyPress "z") {///when the "Z" key in the keyboard is pressed, perform the following action.
Play (); Perform play action
}

As shown in the figure.

KeyPress action

Note-When you add a button to an animated piece, you should put it on a separate layer to make it easier to modify.

Tip--on is the action on the button, so we have to select the button first before we can add the ON statement. Some friends ask questions in the forum, "Why is my on in the gray not selectable state?" "The reason is that you don't have the check button.

Tips-In general flash works, you do not intentionally distinguish these on functions, generally using the default statement. If there are no special instructions, you use drag-and-drop events to make the "replay" button, people will not feel the mind.

Try--we understand on so many functions, using these features can easily produce flash courseware, flash game inside the effect, you may wish to try.

The function of parsing the--on statement is closely related to the button, and there must be a button where the ON statement is used. Where there are flash works, there will be buttons appearing, so the important role of on is not negligible. Today we introduced in detail on the various functions, we can combine the characteristics of the button itself, play their function.

Special Tips

button when a complete flash works in the indispensable parts, so we also need to elaborate.

  Special Notes

This section looks more content, but knowledge is easier to master. For example, in the eight events on, it is common to use releases, slides, and other events with less frequency. But if we make the courseware or the game and so on the work will still use.
The problem with the text button, we've talked about it in the previous section. Be sure to note the response area of the text button.

  Related issues

How do you make a button that you never touch?

We do this by sliding through the events in the on statement and matching the goto statement. We make a button and drag it into the main scene. Copy four frames and change the position of the button in frame 2nd, 3rd stitch, 4th Frame, and 5th. Go back to frame 1th, add a stop on the frame, and let the animation stop at frame 1th.

Add As:on (rollover) to the button in frame 1th {///when the mouse passes, perform the following action.
gotoAndStop (2); Go to and stop at frame 2nd.
}
Add As:on (Rollover) {to the button in frame 2nd
gotoAndStop (3);
}
Add As:on (Rollover) {to the button in frame 3rd
gotoAndStop (4);
}
Add As:on (Rollover) {To button in frame 4th
gotoAndStop (5);
}
Add As:on (Rollover) {To button in frame 5th
gotoAndStop (1);
}

So we have a loop in these five frames and jump in turn, so you'll never 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.