“this” is me

Sometimes its necessary to refere to ourselves. Ha ha, right now I have said so "ourselves", "I" . So how a flash movie or movieclip will say so ?? Well the answer is "this" .What ? Yes, the answer is "this".Like the way we say "its my shirt.".In flash's environment it is known as "this".
Open one flash document and type in the following script in the first frame
trace(this);

Now if you test your movie you will see "_level0" in the output window. Well whats that? That is actually the name of the movie. To understand it better, if you have a name as "Joe" adn somewhere you are saying that "I am great." then actually that sentence meant "Joe is great" is not it?

Lets make a movieclip and name it on stage as "myClip".Now modify our script so it is read as

trace(this);
myClip.onRelease=function(){
trace(this);
}

Now if you test your movie it will show the following result in your output window

_level0
_level0.myClip

Thats because it is saying exactly where is our clip.If we are interested in just the name of our clip then our script will look like

trace(this);
myClip.onRelease=function(){
trace(this._name);
}

The results of this will look as

_level0
myClip

Thats how we target a movie or clip from inside itself.
😉

Advertisements

Author: saumya

designer / developer / maker / educator @saumya

1 thought on ““this” is me”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s