User Guide

692 ActionScript classes
Example
The following example moves a movie clip called
car_mc a constant distance (10) when you
press an arrow key. A sound plays when you press the Spacebar. For this example, 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);
LoadVars
Object
|
+-LoadVars
public dynamic class LoadVars
extends Object
You can use the LoadVars class to obtain verification of successful data loading and to monitor
download progress. The LoadVars class is an alternative to the
loadVariables() function for
transferring variables between a Flash application and a server.