Click on the SWF or move the mouse to activate the text.
The code below shows how the text in a dynamic text field responds to the user moving and clicking with the mouse.
- //Make a dynamic text field named mouse_events
- //The stage will listen for each event and display the related text.
- stage.addEventListener(MouseEvent.MOUSE_DOWN, mouse_down);
- stage.addEventListener(MouseEvent.MOUSE_UP, mouse_up);
- stage.addEventListener(MouseEvent.MOUSE_MOVE, moving);
- stage.addEventListener(MouseEvent.MOUSE_OUT, leave);
- function moving(event:MouseEvent)
- {
- mouse_events.text = "Your mouse is moving";
- }
- function mouse_down(event:MouseEvent)
- {
- mouse_events.text = "The mouse button is down";
- }
- function mouse_up(event:MouseEvent)
- {
- mouse_events.text = "Mouse button is up again";
- }
- function leave(event:MouseEvent)
- {
- mouse_events.text = ""; //No text
- }
CLICK : MouseEvent.CLICK
Used to detect mouse clicks.
DOUBLE_CLICK : MouseEvent.DOUBLE_CLICK
Used to detect double clicks.
MOUSE_DOWN : MouseEvent.MOUSE_DOWN
Checks when mouse is pressed down.
MOUSE_LEAVE : MouseEvent.MOUSE_LEAVE
Monitors when the mouse leaves the stage.
MOUSE_MOVE : MouseEvent.MOUSE_MOVE
Monitors when the mouse moves.
MOUSE_OUT : MouseEvent.MOUSE_OUT
Monitors when the mouse moves out of the attached to object of the event.
MOUSE_OVER : MouseEvent.MOUSE_OVER
Monitors when the mouse moves over the attached to object of the event.
MOUSE_UP : MouseEvent.MOUSE_UP
Monitors when the mouse moves up the attached to object of the event from a click.
MOUSE_WHEEL : MouseEvent.MOUSE_WHEEL
Monitors when the mouse wheel moves, detect the positive or negative delta property for distance and direction moved.
ROLL_OUT : MouseEvent.ROLL_OUT
Dispatched when the user moves a pointing device away from an InteractiveObject instance.
No comments:
Post a Comment