PDA

View Full Version : this.photo



theanimal
November 29th, 2005, 01:03 PM
when some code has this. in front of a mc name (for example, this.photo) what does that mean?

Wizzz
November 29th, 2005, 01:44 PM
have u checked at the maual? :crying:

this references the movie clip instance that contains the script

Loststarz
November 29th, 2005, 01:45 PM
It's "code" that sets out the MC as the parameter which the code refers to.

In English you would have:

Show second state when I rollover this photo.

In AS you use:

this.photo
On_Rollover
gotoandPlay "X" with X refering to the alternate instance of the photo.

Barn
November 29th, 2005, 01:52 PM
It means, in the current path. Generally it is only needed for concatenating and resolving instances and paths with the array access operator, or when directly accessing variables within the scope of a button when done with a button event handler function.

Wizzz
November 29th, 2005, 01:58 PM
something like ./ in your file manager :)

lunatic
November 29th, 2005, 01:58 PM
You can also think of it as the current timeline that the code is written on. So for example, Let's say you have MC1 on the maintimeline and MC2 is inside MC1. If you wanted to write code to start playing from the 5th frame of MC2 you could put the following code on the main timeline (also known as _root)

_root.MC1.MC2.gotoAndPlay(5)

You could also double click on MC1 to "open" it and on IT'S timeline put

this.MC2.gotoAndPlay(5)

You could also double click on MC2 and on IT'S timeline put

this.gotoAndPlay(5)

See? "this" is just a reference to the timeline you are writing the code on.

Hope this helps. :hr: