Scope Of The "This" Keyword - MACROMEDIA FLASH MX 2004 - ACTIONSCRIPT Reference Manual

Actionscript reference guide
Hide thumbs Also See for FLASH MX 2004 - ACTIONSCRIPT:
Table of Contents

Advertisement

Scope of the "this" keyword

The
keyword refers to the object in the currently executing scope. Depending on what type
this
of event handler technique you're using,
Within an event handler or event listener function
event handler or event listener method. For example, in the following code
itself.
myClip
// onPress() event handler attached to _level0.myClip:
myClip.onPress = function () {
trace(this); // displays '_level0.myClip'
}
Within an on() handler attached to a movie clip
handler is attached.
on()
// Attached to movie clip named 'myClip'
on(press) {
trace(this); displays '_level0.myClip'
}
Within an on() handler attached to a button
button.
// Attached to button on main Timeline
on(press) {
trace(this); // displays '_level0'
}
90
Chapter 4: Handling Events
can refer to different objects.
this
,
refers to the object that defines the
this
,
refers to the movie clip to which the
this
,
refers to the Timeline that contains the
this
refers to
this

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the FLASH MX 2004 - ACTIONSCRIPT and is the answer not in the manual?

Subscribe to Our Youtube Channel

Table of Contents