Joke Collection Website - Bulletin headlines - Flash as3 mouse event

Flash as3 mouse event

Detailed description of using Flash AS3 mouse events

Mouse event and mouse position (AS3 mouse coordinate summary) are the most important ways of human-computer interaction in RIA. Recently, I found how superficial my understanding of mouse events was when I was doing ProdutShow, a dynamic product display system. Now that the product demonstration has been completed, let's summarize the problems that should be paid attention to when using mouse events:

1 mouse events are divided into mouse _ over, mouse _ move, mouse _ down, mouse _ up, mouse _ out, mouse _ wheel and MOUSE_LEAVE. The first six events all come from the flash.events.MouseEvent class, but the last MOUSE_LEAVE comes from the flash.events.Event We must pay attention to this problem when importing the class package, because I tried it for a long time before I found the problem.

MOUSE _ OVER- triggered when the mouse moves to the target object, which can be used to simulate the effect of the mouse passing the button;

Mouse _ move-Triggered when the mouse moves to the target object, mainly used for judgment. For example, when dragging an instance, judge whether the instance is within the allowable range, and if it is beyond the allowable range, immediately stop dragging or reset the instance coordinates;

Triggered when the mouse presses the target object. Please note that it will only trigger when the left mouse button is pressed, and neither the right mouse button nor the scroll wheel will trigger. When you press the left mouse button outside the target object and then move to the target object, it will not trigger;

Triggered when the mouse is released on the target object. Please note that it will only trigger when you release the left mouse button, and neither the right mouse button nor the wheel will trigger. It does not trigger when you press the left mouse button on the target object and then move it out of the target object and release it. But when you press the left mouse button outside the target object and then move to the target object and release it, it will be triggered.

MOUSE_OUT- Triggered when the mouse moves out of the target object.

MOUSE _ WHEEL- Triggered when the mouse turns the wheel on the target object.

Mouse Off-Triggered when the cursor leaves the stage. Add an event listener (event. Mouse _ leave, leave handler); )。 After using the custom mouse, the MOUSE_LEAVE event is triggered when the mouse leaves the stage, and then the custom mouse can be hidden to avoid staying on the stage.

Two mice and children. When the target object contains child instances, it is the child time series that senses the mouse behavior, not the target object. If cursor.mouseEnabled = false is used, the target object can reflect the mouse behavior.

3 Mouse enabled. When instances overlap, the instance above the display list always takes precedence over the instance below to perceive mouse behavior. If you want the following instance to be aware of mouse behavior, please use cursor.mouseEnabled = false to do it. This is often used to eliminate the interference of the custom mouse on the mouse behavior after the definition of the custom mouse, because the custom mouse is always under the mouse, and other instances can no longer perceive the changes of the mouse.

In addition, maybe double-clicking should also be counted as a mouse event, but to use it, you must first

doubleClickEnabled=true:

var BG:Sprite = new Sprite();

BG . double click enabled = true;

bg.addEventListener(MouseEvent。 Double-click and click the handler);

Supplementary question: I can register an over event for the button when it is pressed, and delete it immediately after it is used, thus achieving a dragout effect similar to as2, but the response seems to be very slow. Moreover, it is more troublesome, and it is necessary to add a statement delete over to the up event.

If there is no dragout, can you monitor events released outside the object? Upward can only be triggered when it is released within an object.

MOUSE_OUT only triggers when the mouse moves out of the object, not dragout, which can only be triggered by holding down the left button-move out-release.

If you want to use DragDrop, please use DragEvent, please refer to:

/lang ref/MX/events/drag event . html