Left (Key.left Property); Listeners (Key._Listeners Property) - MACROMEDIA FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE Reference

Actionscript 2.0 language reference
Table of Contents

Advertisement

LEFT (Key.LEFT property)

public static LEFT : Number
The key code value for the Left Arrow key (37).
Availability: ActionScript 1.0; Flash Player 5
Example
The following example moves a movie clip called
press an arrow key. A sound plays when you press the Spacebar. Give a sound in the library a
linkage identifier of
horn_id
var DISTANCE:Number = 10;
var horn_sound:Sound = new Sound();
horn_sound.attachSound("horn_id");
var keyListener_obj:Object = new Object();
keyListener_obj.onKeyDown = function() {
switch (Key.getCode()) {
case Key.SPACE :
horn_sound.start();
break;
case Key.LEFT :
car_mc._x -= DISTANCE;
break;
case Key.UP :
car_mc._y -= DISTANCE;
break;
case Key.RIGHT :
car_mc._x += DISTANCE;
break;
case Key.DOWN :
car_mc._y += DISTANCE;
break;
}
};
Key.addListener(keyListener_obj);

_listeners (Key._listeners property)

public static _listeners : Array [read-only]
A list of references to all listener objects that are registered with the Key object. This property
is intended for internal use, but it may be useful if you want to ascertain the number of
listeners currently registered with the Key object. Objects are added to and removed from this
array by calls to the
addListener()
Availability: ActionScript 1.0; Flash Player 6
car_mc
for this example.
and
removelistener()
a constant distance (10) when you
methods.
Key
685

Hide quick links:

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?

Subscribe to Our Youtube Channel

This manual is also suitable for:

Flash 8

Table of Contents

Save PDF