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.

See also<br />

addListener (Mouse.addListener method)<br />

onMouseMove (Mouse.onMouseMove event<br />

listener)<br />

onMouseMove = function() {}<br />

Notified when the mouse moves. To use the onMouseMove listener, you must create a listener<br />

object. You can then define a function for onMouseMove <strong>and</strong> use addListener() to register<br />

the listener with the Mouse object, as shown in the following code:<br />

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

someListener.onMouseMove = function () { ... };<br />

Mouse.addListener(someListener);<br />

Listeners enable different pieces of code to cooperate because multiple listeners can receive<br />

notification about a single event.<br />

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

is true.<br />

Example<br />

The following example uses the mouse pointer as a tool to draw lines using onMouseMove <strong>and</strong><br />

the Drawing API. The user draws a line by moving the pointer.<br />

this.createEmptyMovieClip("canvas_mc", this.getNextHighestDepth());<br />

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

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

this.isDrawing = true;<br />

canvas_mc.lineStyle(2, 0xFF0000, 100);<br />

canvas_mc.moveTo(_xmouse, _ymouse);<br />

};<br />

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

if (this.isDrawing) {<br />

canvas_mc.lineTo(_xmouse, _ymouse);<br />

}<br />

updateAfterEvent();<br />

};<br />

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

this.isDrawing = false;<br />

};<br />

Mouse.addListener(mouseListener);<br />

The following example sets the x <strong>and</strong> y positions of the pointer_mc movie clip instance to<br />

the x <strong>and</strong> y pointer positions. The device must support a stylus or mouse for this example to<br />

work. To use the example, you create a movie clip <strong>and</strong> set its Linkage identifier to<br />

pointer_id. Then add the following ActionScript code to Frame 1 of the Timeline:<br />

Mouse 397

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

Saved successfully!

Ooh no, something went wrong!