03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

See also<br />

addListener (Mouse.addListener method), mouseWheelEnabled<br />

(TextField.mouseWheelEnabled property)<br />

removeListener (Mouse.removeListener method)<br />

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

Removes an object that was previously registered with addListener().<br />

Availability: <strong>ActionScript</strong> 1.0; Flash Player 6<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 is not successfully removed (for example, if the listener was not on the Mouse<br />

object's 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 <strong>ActionScript</strong> 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 />

};<br />

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

if (this.isDrawing) {<br />

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

Mouse 825

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

Saved successfully!

Ooh no, something went wrong!