Scope of the "this" keyword

The this keyword refers to the object in the currently executing scope. Depending on what type of event handler technique you're using, this can refer to different objects.

Within an event handler or event listener function, this refers to the object that defines the event handler or event listener method. For example, in the following code this refers to myClip itself.

// onPress() event handler attached to _level0.myClip:
myClip.onPress = function () {
  trace(this); // displays '_level0.myClip'
}

Within an on() handler attached to a movie clip, this refers to the movie clip to which the on() handler is attached.

// Attached to movie clip named 'myClip'
on(press) {
  trace(this); displays '_level0.myClip'
}

Within an on() handler attached to a button, this refers to the Timeline that contains the button.

// Attached to button on main Timeline
on(press) {
  trace(this); // displays '_level0'
}