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

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

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

emoveListener (Key.removeListener method)<br />

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

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

Parameters<br />

listener:Object - An object.<br />

Returns<br />

Boolean - If the listener was successfully removed, the method returns true. If the<br />

listener was not successfully removed (for example, because the listener was not on the<br />

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

Example<br />

The following example moves a movie clip called car_mc using the Left <strong>and</strong> Right arrow keys.<br />

The listener is removed when you press Escape, <strong>and</strong> car_mc no longer moves.<br />

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

keyListener.onKeyDown = function() {<br />

switch (Key.getCode()) {<br />

case Key.LEFT :<br />

car_mc._x -= 10;<br />

break;<br />

case Key.RIGHT :<br />

car_mc._x += 10;<br />

break;<br />

case Key.ESCAPE :<br />

Key.removeListener(keyListener);<br />

}<br />

};<br />

Key.addListener(keyListener);<br />

RIGHT (Key.RIGHT property)<br />

public static RIGHT : Number<br />

The key code value for the Right Arrow key (39).<br />

Example<br />

The following example moves a movie clip called car_mc a constant distance (10) when you<br />

press the arrow keys. A sound plays when you press the Spacebar. Give a sound in the library a<br />

linkage identifier of horn_id for this example.<br />

var DISTANCE:Number = 10;<br />

var horn_sound:Sound = new Sound();<br />

358 ActionScript classes

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

Saved successfully!

Ooh no, something went wrong!