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.

this.attachMovie("pointer_id", "pointer_mc", this.getNextHighestDepth());<br />

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

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

pointer_mc._x = _xmouse;<br />

pointer_mc._y = _ymouse;<br />

};<br />

Mouse.addListener(mouseListener);<br />

See also<br />

addListener (Mouse.addListener method)<br />

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

onMouseUp = function() {}<br />

Notified when the mouse button is released. To use the onMouseUp listener, you must create a<br />

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

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

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

someListener.onMouseUp = 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 or System.capabilities.hasStylus 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 <strong>and</strong> stops drawing the line by<br />

releasing the mouse button.<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 />

398 ActionScript classes

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

Saved successfully!

Ooh no, something went wrong!