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.isDrawing = false;<br />

};<br />

Mouse.addListener(mouseListener);<br />

See also<br />

addListener (Mouse.addListener method)<br />

removeListener (Mouse.removeListener method)<br />

public static removeListener(listener:Object) : Boolean<br />

Removes an object that was previously registered with addListener().<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 />

Returns<br />

Boolean - If the listener object is successfully removed, the method returns true; if the<br />

listener object is not successfully removed (for example, if it was not on the Mouse object's<br />

listener list), the method returns false.<br />

Example<br />

The following example attaches three buttons to the Stage, <strong>and</strong> lets the user draw lines in the<br />

SWF file at runtime, using the mouse pointer. One button clears all of the lines from the<br />

SWF file. The second button removes the mouse listener so the user cannot draw lines. The<br />

third button adds the mouse listener after it is removed, so the user can draw lines again. Add<br />

the following ActionScript to Frame 1 of the Timeline:<br />

this.createClassObject(mx.controls.Button, "clear_button",<br />

this.getNextHighestDepth(), {_x:10, _y:10, label:'clear'});<br />

this.createClassObject(mx.controls.Button, "stopDrawing_button",<br />

this.getNextHighestDepth(), {_x:120, _y:10, label:'stop drawing'});<br />

this.createClassObject(mx.controls.Button, "startDrawing_button",<br />

this.getNextHighestDepth(), {_x:230, _y:10, label:'start drawing'});<br />

startDrawing_button.enabled = false;<br />

//<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 />

Mouse 399

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

Saved successfully!

Ooh no, something went wrong!