View comments | RSS feed

_root

Availability

Flash Player 5.

Usage

_root.movieClip
_root.action
_root.property

Parameters

movieClip The instance name of a movie clip.

action An action or method.

property A property of the MovieClip object.

Description

Identifier; specifies or returns a reference to the root movie clip Timeline. If a movie clip has multiple levels, the root movie clip Timeline is on the level containing the currently executing script. For example, if a script in level 1 evaluates _root, _level1 is returned.

Specifying _root is the same as using the deprecated slash notation (/) to specify an absolute path within the current level.

Caution: If a movie clip that contains _root is loaded into another movie clip, _root refers to the Timeline of the loading movie clip, not the Timeline that contains _root. If you want to ensure that _root refers to the Timeline of the loaded movie clip even if it is loaded into another movie clip, use MovieClip._lockroot.

Example

The following example stops the Timeline of the level containing the currently executing script:

_root.stop();

The following example traces variables and instances in the scope of _root:

for (prop in _root) {
   trace("_root."+prop+" = "+_root[prop]);
}

See also

MovieClip._lockroot, _parent, targetPath()

Comments


No screen name said on Mar 8, 2005 at 3:44 AM :
There could be a notice somewhere that FlashVars parameter can be used to set _root level variables. I was not able to find any information about FlashVars in the current documentation.
No screen name said on Mar 29, 2005 at 8:46 PM :
Hey,

How can you populate a dynamic text element inside a movieClip that has a dynamically create instance name?

Below I have successfully attached a movieClip (with a dynamically created instance name) and wish to populate a text field (nameText) that resides within it.

** START CODE ******************************

msgFrom = mesg.substr(mesg.indexOf('(') + 1, mesg.indexOf(')') - mesg.indexOf('(') - 1);
movName = 'private_' + msgFrom;
_root.attachMovie("mc_privChatWin", movName, 9879);
_root.movName.nameText.htmlText = msgFrom;


** END CODE ******************************

Thanks a lot!
MechKurt said on Oct 3, 2005 at 1:59 AM :
i know that it's posible to dynamicaly found clip that way:
clipArray = ['1_mc','a_mc','circle_mc','square'];
for (var j=0;j<clipArray .length;j++) {
_root[clipArray [j]]._x = Math.rand()*200;
}
but that works only if the clip are on the main timeline of the _root (or _level0) movie...

what if you want to acceed somme clips which are in subclip
like this:
for (var j=0;j<clipArray .length;j++) {
_root.tiles_mc[clipArray [j]]._x = Math.rand()*200;
}
I tried different ways but none seems to work...
MechKurt said on Oct 5, 2005 at 10:04 AM :
the correct way seems to be
for (var j=0;j<clipArray .length;j++) {
tiles_mc[clipArray [j]]._x = Math.random()*200;
}
but
tiles_mc[clipArray[j]].duplicateMovieClip("new_mc",this.getNextHighestDepth());
doesn't work !

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/mx2004/main_7_2/00001649.html