03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

■ keyUp The action is initiated when a key is released. Use the Key.getCode() method to<br />

retrieve information about the last key pressed.<br />

■ data The action is initiated when data is received in a loadVariables() or loadMovie()<br />

action. When specified with a loadVariables() action, the data event occurs only once,<br />

when the last variable is loaded. When specified with a loadMovie() action, the data<br />

event occurs repeatedly, as each section of data is retrieved.<br />

Example<br />

The following example uses onClipEvent() with the keyDown movie event <strong>and</strong> is designed to<br />

be attached to a movie clip or button. The keyDown movie event is usually used with one or<br />

more methods <strong>and</strong> properties of the Key object. The following script uses Key.getCode() to<br />

find out which key the user has pressed; if the pressed key matches the Key.RIGHT property,<br />

the playhead is sent to the next frame; if the pressed key matches the Key.LEFT property, the<br />

playhead is sent to the previous frame.<br />

onClipEvent (keyDown) {<br />

if (Key.getCode() == Key.RIGHT) {<br />

this._parent.nextFrame();<br />

} else if (Key.getCode() == Key.LEFT) {<br />

this._parent.prevFrame();<br />

}<br />

}<br />

The following example uses onClipEvent() with the load <strong>and</strong> mouseMove movie events.<br />

The _xmouse <strong>and</strong> _ymouse properties track the position of the mouse each time the mouse<br />

moves, which appears in the text field that's created at runtime.<br />

onClipEvent (load) {<br />

this.createTextField("coords_txt", this.getNextHighestDepth(), 0, 0, 100,<br />

22);<br />

coords_txt.autoSize = true;<br />

coords_txt.selectable = false;<br />

}<br />

onClipEvent (mouseMove) {<br />

coords_txt.text = "X:"+_root._xmouse+",Y:"+_root._ymouse;<br />

}<br />

See also<br />

Key, _xmouse (MovieClip._xmouse property), _ymouse (MovieClip._ymouse<br />

property), on h<strong>and</strong>ler, updateAfterEvent function<br />

88 <strong>ActionScript</strong> language elements

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

Saved successfully!

Ooh no, something went wrong!