- Home
- Tutorials
- Flash
- Intermediate
- Advanced Pathing

More relative paths
Jesse Stratford
Jesse lives and works in Melbourne Australia. He is the Cofounder of http://ActionScript.org. A Flash enthusiast, teacher, author, freelancer and speaker Jesse's main focus nowadays is managing http://ActionScript.org, but he enjoys participating actively in community and the wider Flash scene when he has time.
View all articles by Jesse Stratford
_parent is perhaps more obviously useful at first. Take another look at the diagram to the left and recall the steps analogy. We know that step 2 is one step back from step 3. We know that Clip1 is one step up (back) from Clip2; that is, Clip2 is on Clip1's timeline. Clip1 is therefore called Clip2's parent. So when we want to make reference to Clip1 from Clip2 we needn't give the full path from _root. Instead we use the relative path:_parent.variable = value;
Got it? The Main Timeline (_root) is the parent of Clip1. So if we're in Clip1 and we want to make reference to something on the main timeline we can use:
_parent.variable = value;
Of course, in this case we save ourselves no typing as _root.variable is less characters than _parent.variable, but recall the loadMovie example. Were we to load this SWF into a movieclip with the _root reference, it would look on the _root of the SWF that loaded it. With the _parent syntax we ensure it just looks to its parent timeline for the value.
The _parent parameter is stackable also. So if we're on the timeline of Clip2 and we want to go 'up' two levels to the Main Timeline, we can use:
_parent._parent.variable = value;
The first _parent takes us from Clip2 to Clip1, the second from Clip1 to the Main Timeline (which in this example is _root, but again, in the loadMovie example may be something completely different).
So that's it really. Experimentation is the name of the game now boys and girls. Practice is the best way to become familiar with this stuff. Soon it will be second nature. Good luck.
| Jesse Stratford is the Co-Master of ActionScript.org and a freelance Flash developer and teacher. He is based in Australia and enjoys all things Flash. NB: If you have comments or feedback please feel free to email me, but please do not email me Flash questions; the forums are provided for that purpose and you will get a faster answer by posting you question there. |
If you have found this tutorial helpful, I hope that you will take 30 seconds to visit The Hunger Site where, with just one click you can make a free donation of food to a starving person in a third-world country. We do not benefit financially from this action; it is purely an act of charity. |
| This tutorial is protected by International Intellectual Property Rights laws and may not be reproduced or redistributed in full or part, without the prior written consent of the author. Unauthorized reproduction of this tutorial or its contents may result in prosecution. I've worked hard on this tutorial, please don't steal it. |


