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.

}<br />

};<br />

Key.addListener(keyListener);<br />

When using this example, make sure that you select Control > Disable Keyboard Shortcuts in<br />

the test environment.<br />

UP (Key.UP property)<br />

public static UP : Number<br />

The key code value for the Up Arrow key (38).<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 />

horn_sound.attachSound("horn_id");<br />

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

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

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

case Key.SPACE :<br />

horn_sound.start();<br />

break;<br />

case Key.LEFT :<br />

car_mc._x -= DISTANCE;<br />

break;<br />

case Key.UP :<br />

car_mc._y -= DISTANCE;<br />

break;<br />

case Key.RIGHT :<br />

car_mc._x += DISTANCE;<br />

break;<br />

case Key.DOWN :<br />

car_mc._y += DISTANCE;<br />

break;<br />

}<br />

};<br />

Key.addListener(keyListener_obj);<br />

LoadVars<br />

Object<br />

|<br />

+-LoadVars<br />

LoadVars 361

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

Saved successfully!

Ooh no, something went wrong!