# When to use \_root?

**URL:** <https://forum.kirupa.com/t/when-to-use--root/186320>\
**Category:** flash\
**Created:** [April 20, 2006, 3:06pm UTC](https://forum.kirupa.com/t/when-to-use--root/186320 "2006-04-20T15:06:15Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![dexa\_007](https://avatars.discourse-cdn.com/v4/letter/d/f17d59/32.png) [@dexa\_007](https://forum.kirupa.com/u/dexa_007)\
**Post date:** [April 20, 2006, 3:06pm UTC](https://forum.kirupa.com/t/when-to-use--root/186320/1 "2006-04-20T15:06:15Z")

</div>

Noob question here: I know it’s sometimes necessary to include \_root in your actionscript. Can anyone provide an explanation of when it’s appropriate?

Thanks!

---

<div class="post-metadata">

**Author:** ![JoshuaJonah](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joshuajonah/32/1775_2.png) [@JoshuaJonah](https://forum.kirupa.com/u/JoshuaJonah)\
**Post date:** [April 20, 2006, 3:09pm UTC](https://forum.kirupa.com/t/when-to-use--root/186320/2 "2006-04-20T15:09:16Z")

</div>

It’s never completely neccesary. Theres always a way to get around it and avoid it. I recommend using a variable for the \_root of the current clip your working on. You can put this in the root timeline of you movie:

```auto
var this_clips_root:MovieClip = this;

```

Then you can refer to “this\_clips\_root” instead of “\_root”

---

<div class="post-metadata">

**Author:** ![lunatic](https://avatars.discourse-cdn.com/v4/letter/l/73ab20/32.png) [@lunatic](https://forum.kirupa.com/u/lunatic)\
**Post date:** [April 20, 2006, 4:06pm UTC](https://forum.kirupa.com/t/when-to-use--root/186320/3 "2006-04-20T16:06:28Z")

</div>

In a nutshell, \_root refers to your main timeline. If you have code buried in several nested movieclips but you want to target something on the main timeline you can simply use \_root.NameOfObject.

You can sort of think of it like using windows explorer (if you have a pc). Imagine the C:/ drive is the \_root timeline, a movieclip on the \_root is a folder on the C:/ drive. A movieclip within that movieclip is like a subfolder within that folder, and a textbox (or what have you) within that nested movieclip is like a text file inside the subfolder, e.g.

C:/folder1/folder2/mytext.txt == \_root.MovieClip1.MovieClip2.mytext.txt

SO, if you are writing code on the timeline of MovieClip2 and want to target MovieClip1 there are several ways to do it. You can use \_parent to tell flash to go out one timeline (one level above) as in \_parent.MovieClip1 or you can use \_root to start at the main timeline and work in like \_root.MovieClip1.

The advantage comes in when you have really deeply nested objects like  
\_root.MC1.MC2.MC3.MC4.MC5.MC6.MC7. If you are writing code at the timeline of MC6 and want to get to MC1 you could write

\_parent.\_parent.\_parent.\_parent.\_parent.MC1 or you could write \_root.MC1

More explanation than you ever wanted but hopefully it makes sense! 😛

---

<div class="post-metadata">

**Author:** ![dexa\_007](https://avatars.discourse-cdn.com/v4/letter/d/f17d59/32.png) [@dexa\_007](https://forum.kirupa.com/u/dexa_007)\
**Post date:** [April 20, 2006, 4:30pm UTC](https://forum.kirupa.com/t/when-to-use--root/186320/4 "2006-04-20T16:30:35Z")

</div>

Much appreciated!! 🍺 Thanks guys!

---

<div class="post-metadata">

**Author:** ![JoshuaJonah](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/joshuajonah/32/1775_2.png) [@JoshuaJonah](https://forum.kirupa.com/u/JoshuaJonah)\
**Post date:** [April 20, 2006, 4:32pm UTC](https://forum.kirupa.com/t/when-to-use--root/186320/5 "2006-04-20T16:32:46Z")

</div>

np:mountie:
