•
Assign the following
and press the desired key.
onClipEvent(keyDown) {
trace(Key.getCode());
}
The key code of the desired key appears in the Output panel.
A common place to use Key class methods is within an event handler. In the following example,
the user moves the car using the arrow keys. The
key being pressed is the right, left, up, or down arrow. The event handler,
determines the
Key.isDown(keyCode)
the handler instructs Flash Player to update the position of the car and to display the direction.
The input from the keyboard keys moves the car.
The following procedure shows how to capture keypresses to move a movie clip up, down, left, or
right on the Stage, depending on which corresponding arrow key (up, down, left, or right) is
currently pressed. The movie clip is confined to an arbitrary area that is 400 pixels wide and 300
pixels high. Also, a text field displays the name of the pressed key.
handler to a movie clip, then select Control > Test Movie
onClipEvent()
value from the
method indicates whether the
Key.isDown()
statements. Depending on the value,
if
Creating interactivity and visual effects
,
onEnterFrame
97
Need help?
Do you have a question about the FLASH MX 2004 - ACTIONSCRIPT and is the answer not in the manual?