N-R > onClipEvent

onClipEvent

Syntax

onClipEvent(movieEvent);{
...
}

Arguments

A movieEvent is a trigger event that executes actions that are assigned to a movie clip instance. Any of the following values can be specified for the movieEvent argument:

load The action is initiated as soon as the movie clip is instantiated and appears in the Timeline.
unload The action is initiated in the first frame after the movie clip is removed from the Timeline. The actions associated with the Unload movie clip event are processed before any actions are attached to the affected frame.
enterFrame The action is initiated as each frame is played, similar to actions attached to a movie clip. The actions associated with the OnEnterFrame movie clip event are processed after any actions that are attached to the affected frames.
mouseMove The action is initiated every time the mouse is moved. Use the _xmouse and _ymouse properties to determine the current mouse position.
mouseDown The action is initiated when the left mouse button is pressed.
mouseUp The action is initiated when the left mouse button is released.
keyDown The action is initiated when a key is pressed. Use the Key.getCode method to retrieve information about the last key pressed.
keyUp The action is initiated when a key is released. Use the Key.getCode method to retrieve information about the last key pressed.
data The action is initiated when data is received in a loadVariables or loadMovie action. When specified with a loadVariables action, the data event occurs only once, when the last variable is loaded. When specified with a loadMovie action, the data event occurs repeatedly, as each section of data is retrieved.

Description

Handler; triggers actions defined for a specific instance of a movie clip.

Player

Flash 5 or later.

Example

The following statement includes the script from an external file when the movie clip instance is loaded and first appears on the Timeline:

onClipEvent(load) {
	#include "myScript.as"
}

The following example uses onClipEvent with the keyDown movie event. The keyDown movie event is usually used in conjunction with one or more methods and properties associated with the Key object. In the script below, key.getCode is used to find out which key the user has pressed; the returned value is associated with the RIGHT or LEFT Key object properties, and the movie is directed accordingly.

onClipEvent(keyDown) {
	if (Key.getCode() == Key.RIGHT) {
		} _parent.nextFrame();
	else if (Key.getCode() == Key.LEFT){
		_parent.prevFrame();
}

The following example uses onClipEvent with the mouseMove movie event. The the xmouse and ymouse properties track the position of the mouse.

onClipEvent(mouseMove) {
stageX=_root.xmouse;
stageY=_root.ymouse;
}

See also

on(mouseEvent)
Key (object)
_xmouse
_ymouse