03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The listener parameter should contain an object that has a defined method for at least one<br />

of the listeners.<br />

When the mouse button is pressed, moved, released, or used to scroll, regardless of the input<br />

focus, all listening objects that are registered with this method have their onMouseDown,<br />

onMouseMove, or onMouseUp method invoked. Multiple objects can listen for mouse<br />

notifications. If the listener is already registered, no change occurs.<br />

Note: This method is supported in Flash Lite only if System.capabilities.hasMouse is<br />

true or System.capabilities.hasStylus is true.<br />

Parameters<br />

listener:Object - An object.<br />

Example<br />

This example is excerpted from the animation.fla file in the ActionScript Samples folder.<br />

// Create a mouse listener object.<br />

var mouseListener:Object = new Object();<br />

// Every time the mouse cursor moves within the SWF file,<br />

update the position of the crosshair movie clip<br />

instance on the Stage.<br />

mouseListener.onMouseMove = function() {<br />

crosshair_mc._x = _xmouse;<br />

crosshair_mc._y = _ymouse;<br />

};<br />

// When you press the mouse button, check to see if the cursor is within the<br />

boundaries of the Stage. If so, increment the number of shots.<br />

mouseListener.onMouseDown = function() {<br />

if (bg_mc.hitTest(_xmouse, _ymouse, false)) {<br />

_global.shots++;<br />

}<br />

};<br />

Mouse.addListener(mouseListener);<br />

To view the entire script, see the animation.fla file in the ActionScript samples folder at<br />

www.adobe.com/go/learn_fl_samples. Download <strong>and</strong> decompress the .zip file <strong>and</strong> navigate to<br />

the folder for your version of ActionScript to access the sample.<br />

See also<br />

onMouseDown (Mouse.onMouseDown event listener), onMouseMove<br />

(Mouse.onMouseMove event listener), onMouseUp (Mouse.onMouseUp event<br />

listener)<br />

Mouse 395

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!