User Guide

544 Chapter 2: ActionScript Language Reference
_lockroot -> true
$version -> WIN 7,0,19,0
The following example loads two SWF files, lockroot.swf and nolockroot.swf. The lockroot.fla
document contains the previous ActionScript. The nolockroot FLA file has the following code
placed on Frame 1 of the Timeline:
_root.myVar = 1;
_root.myOtherVar = 2;
trace("from nolockroot.swf");
for (i in _root) {
trace(" "+i+" -> "+_root[i]);
}
trace("");
The lockroot.swf file has _lockroot applied to it, and nolockroot.swf does not. After the files are
loaded, each file dumps variables from their
_root scopes. Place the following ActionScript on
the main Timeline of a FLA document:
this.createEmptyMovieClip("lockroot_mc", this.getNextHighestDepth());
lockroot_mc.loadMovie("lockroot.swf");
this.createEmptyMovieClip("nolockroot_mc", this.getNextHighestDepth());
nolockroot_mc.loadMovie("nolockroot.swf");
function dumpRoot() {
trace("from current SWF file");
for (i in _root) {
trace(" "+i+" -> "+_root[i]);
}
trace("");
}
dumpRoot();
which traces the following information:
from current SWF file
dumpRoot -> [type Function]
$version -> WIN 7,0,19,0
nolockroot_mc -> _level0.nolockroot_mc
lockroot_mc -> _level0.lockroot_mc
from nolockroot.swf
myVar -> 1
i -> lockroot_mc
dumpRoot -> [type Function]
$version -> WIN 7,0,19,0
nolockroot_mc -> _level0.nolockroot_mc
lockroot_mc -> _level0.lockroot_mc
from lockroot.swf
myOtherVar -> 2
myVar -> 1
The file with no _lockroot applied contains all of the other variables contained in the root SWF
as well. If you dont have access to the nolockroot.fla, then you can change the
_lockroot in the
main FLA document above using the following ActionScript added to the main Timeline:
this.createEmptyMovieClip("nolockroot_mc", this.getNextHighestDepth());