A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: _root.xyzxyz What this _root means?

  1. #1
    Junior Member
    Join Date
    Jul 2004
    Posts
    21

    _root.xyzxyz What this _root means?

    What is the meaning of _root. What does it represent.

  2. #2
    Denim Demon
    Join Date
    Jun 2002
    Location
    Outside of society
    Posts
    514
    _root is the name of the movie's main timeline as opposed to a movie clip's timeline.

    It tells the Flash player what timeline to target.

    The _root level is the outer most level of movie clips.

    In cases where you are using loadMovie, _root can also mean the outer most level of *the loaded movie* but not necessarily the parent movie.
    In those cases, you might also want to use _level0 to refer to the parent or base movie.

    Hope that helps.

    D
    Davy Paycheck- Kicking more ass than your daddy on a 3 bottle night.

  3. #3
    Left-Handed Flash User mickbrit55's Avatar
    Join Date
    Nov 2003
    Location
    NJ USA
    Posts
    1,375
    Hello

    _root is a reference to the main timeline of your movie in ActionScript. You can use it from any other clip to get access to the main timeline :

    //from within a remote mc
    on(release) {
    _root.gotoAndStop("graphics");
    }

    Mick.

  4. #4
    Junior Member
    Join Date
    Jul 2004
    Posts
    21

    Re:

    ......
    ......
    _root is the name of the movie's main timeline as opposed to a movie clip's timeline.
    It tells the Flash player what timeline to target.
    The _root level is the outer most level of movie clips.
    In cases where you are using loadMovie, _root can also mean the outer most level of *the loaded movie* but not necessarily the parent movie.
    In those cases, you might also want to use _level0 to refer to the parent or base movie.
    .....
    Yah, I understood it somewhat. But what is it used for, ie. when will i need it. Moreover, will i have to manually see the level of my movie or can i get it automatically from the program.

  5. #5
    Denim Demon
    Join Date
    Jun 2002
    Location
    Outside of society
    Posts
    514
    You will need to indicate _root any time you wish to target the root timeline from within another timeline. Also you will need to indicate _root followed by the path to any object on the root timeline if you wish to target objects from within other objects.
    For example, here is a button inside a movie clip telling the root level to play:

    myMC_mc.myButton_btn.onPress = function (){
    _root.play();
    }
    Davy Paycheck- Kicking more ass than your daddy on a 3 bottle night.

  6. #6
    Left-Handed Flash User mickbrit55's Avatar
    Join Date
    Nov 2003
    Location
    NJ USA
    Posts
    1,375
    Hello

    If you have a movie clip that holds a button, and you want it to send the playhead to a frame label called "contact" on the MAIN timeline, then your code on the button would be :

    on(release) {
    _root.gotoAndStop("contact");
    }

    If you didn't use _root the code would be looking for the frame label on the CLIP's timeline, and it wouldn't work.

    If you load an external swf file into your movie using loadMovie(), then things get a little more tricky. Using _root within the loaded swf refers to the main timeline of the swf, not the one that called it. If you want to refer to the calling movie then you would have to use _level0 :

    on(release) {
    _level0.gotoAndStop("contact");
    }

    Mick

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center