Example
In the following example, lockroot.fla has
SWF file is loaded into another FLA document,
lockroot.swf, which helps prevent conflicts. Place the following ActionScript on the main
Timeline of lockroot.fla:
this._lockroot = true;
_root.myVar = 1;
_root.myOtherVar = 2;
trace("from lockroot.swf");
for (i in _root) {
trace(" "+i+" -> "+_root[i]);
}
trace("");
which traces the following information:
from lockroot.swf
myOtherVar -> 2
myVar -> 1
_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 ActionScript from the preceding example. The
nolockroot.fla file has the following code added to 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 _
are loaded, each file outputs the values variables from their
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();
896
ActionScript classes
_lockroot
applied to it, and nolockroot.swf does not. After the files
lockroot
applied to the main SWF file. If the
always refers to the scope of
_root
scopes. Place the following
_root
Need help?
Do you have a question about the FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE and is the answer not in the manual?