Monday, May 26, 2008

Difference between _root and _parent

Hi,
This is my first post....
Let me start with what is the difference between _root and _parent in flash....
This will be useful for the person who likes to goto flash Action script who knows flash...

Both _root and _parent can be used for referring a object in action script.

_root
is used for referring the top most level of object.
for example
if you creat a movie clip called mc_one and mc_two inside mc_one then the _root refer outside the mc_one. that is the first level of the object.
_root -> mc_one -> mc_two
note : if you load a movie clip inside another flash file then the loading movie clip will not be considered as the _root instead of that the main movie clip will be considered as the _root
for example
take the previous example (_root ->mc_one -> mc_two) is loaded in another file then the loaded file will not have _root only the main file witch loading will have _root
_root->loading_mc->mc_one->mc_two

_parent
This is used to go to one step backwards.
for example
consider the same example _root -> mc_one -> mc_two
and wright the script in mc_two it will refer to mc_one
and if we want to refer to more upper level we can use _parent._parent

Conclusion
so it will be better to use _parent since even if you make multiple level of file and made it to link from another file it will not affect the separate file...

Hope it will be helpfull for action script beginners

No comments: