T-W > this

this

Syntax

this

Arguments

None.

Description

Keyword; references an object or movie clip instance. The keyword this has the same purpose and function in ActionScript as it does in JavaScript, with some additional functionality. In ActionScript, when a script executes, this references the movie clip instance that contains the script. When used with a method invocation, this contains a reference to the object that contains the executed method.

Player

Flash 5 or later.

Example

In the following example, the keyword this references the Circle object:

function Circle(radius){
	this.radius = radius;
	this.area = math.PI * radius * radius;
}

In the following statement assigned to a frame, the keyword this references the current movie clip:

//sets the alpha property of the current movie clip to 20.
this._alpha = 20;

In the following statement inside an onClipEvent handler, the keyword this references the current movie clip:

//when the movie clip loads, a startDrag operation is initiated for the current movie clip.

onClipEvent (load) {
 startDrag (this, true);
}

See also

new