PDA

View Full Version : the "this" statement



Dewfiend
February 17th, 2005, 02:56 PM
what does the this statement do? could i use it to call a random image and relocate it on the stage?

lunatic
February 17th, 2005, 03:02 PM
this just refers to the timeline of the object you have the code on. So say you have a movieclip. That movieclip has it's own timeline independent of the _root/main timeline right? If you were to use this.gotoAndPlay(16) on the movieclip Flash would go to and play from frame 16 of the movieclip's timeline, rather than frame 16 of the main timeline.

hope this helps

:hr:

senocular
February 17th, 2005, 03:03 PM
this represents the current "scope" and nothing more. If you define a function for a movie clip, using this in the function lets you reference that movie clip as though you were using its instance name. The advantage of using this is that you can use that same function for multiple movie clips without having to use each of those clips own names, just use this and it will reference the correct clip (the clip the current instance of the function is defined in)

lunatic beat me to it ;)

lunatic
February 17th, 2005, 03:04 PM
but you said it so eloquently (and then some) :love:

*edit* and anyway I learned it from your oop tutorial so really I'm just regurgitating your words :P

see everyone - tutorials are worth the time! :D