Flash MX/ActionScript Graphics Tutorial (eight)

Source: Internet
Author: User
Tutorial 2.1 Mouse and keyboard events
The mouse event can be said to be the most applied event, so let's start with the mouse event to see how flash should react when the user swings the mouse on the screen.

2.1.1 Mouse Down (on (press))
If the code for an interface element (such as a button or an instance of a movie clip) contains an event-handling code such as on (press), then the code in the curly braces behind on is executed when the user presses the mouse over the interface element.

2.1.2 Mouse Release (ON)
This event occurs when the mouse is released, usually after on (press), with press in order to release it! For example, when we need to handle an event that a user clicks on a button, you can add an on event handler for the button. While the role of On (press) and on (release) is similar in this case, because it is usually always release after press, we should still try to use on. Because if you use on (press) will make your button "too sensitive"--one click, the code is immediately executed, if the user found himself pressed the wrong, there is no regret medicine to eat. When using on (release), once the user found that the wrong, you can hold down the mouse button, the mouse pointer to move outside the button released, the code will not be executed, this is the more humane button behavior.

2.1.3 Release Mouse Externally (on (releaseoutside))
The Releaseoutside event occurs when the user presses the mouse over a button or movie clip instance (note that the mouse button is pressed), and then drags the mouse pointer outside the button or movie clip instance to release the mouse. We can capture and handle this event by adding on (releaseoutside) to this button or the event handling code of the movie clip.

2.1.4 Mouse hover (on (rollover))
The rollover event occurs when the mouse pointer is over an interface element. The most typical application of this event is to make the feedback effect of the mouse pointing to a button or movie clip instance: a button color change, a pop-up menu, or some other action.

2.1.5 Mouse Out (on (RollOut))
This event is relative to rollover, and it is obvious that when the mouse pointer moves over an interface element to produce a rollover event, then the mouse pointer is moved out of the interface object and the rollout event occurs. The way out of the rollout event Iherollover events are often handled in pairs, for example, when we capture the rollover event and pop a menu in on (rollover), then obviously we also need to capture the rollout event, on the Rollover) to add the appropriate code to hide the pop-up menu, otherwise the menu will always appear on the interface.

2.1.6 drag skimming (on (dragOver)
We are all familiar with the drag operation, that is, the mouse is pressed on an object after it is not released, and then drag the mouse. The DragOver event is the event that occurs when the mouse pointer is over an object while it is dragging. When making a drag effect, we often have to deal with such events.

2.1.7 Drag Out (On (dragout))
As can be seen from the name, Dragout and DragOver are exactly the opposite, which is what happens when the mouse moves out of an object when it is dragged.

2.1.8 Keyboard event (On (keypress "<>"))
This event needs to be used when we need to capture the user's key action, for example, if you need to capture the user's left arrow key, use on (keypress) "), the other, and so on.

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.