03.05.2013 Views

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

FLASH® LITE™ 2.x - Adobe Help and Support

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Example<br />

In the following example, lockroot.fla has _lockroot applied to the main SWF file. If the<br />

SWF file is loaded into another FLA document, _root always refers to the scope of<br />

lockroot.swf, which helps prevent conflicts. Place the following ActionScript on the main<br />

Timeline of lockroot.fla:<br />

this._lockroot = true;<br />

_root.myVar = 1;<br />

_root.myOtherVar = 2;<br />

trace("from lockroot.swf");<br />

for (i in _root) {<br />

trace(" "+i+" -> "+_root[i]);<br />

}<br />

trace("");<br />

which traces the following information:<br />

from lockroot.swf<br />

myOtherVar -> 2<br />

myVar -> 1<br />

_lockroot -> true<br />

$version -> WIN 7,0,19,0<br />

The following example loads two SWF files, lockroot.swf <strong>and</strong> nolockroot.swf. The<br />

lockroot.fla document contains the ActionScript from the preceding example. The nolockroot<br />

FLA file has the following code placed on Frame 1 of the Timeline:<br />

_root.myVar = 1;<br />

_root.myOtherVar = 2;<br />

trace("from nolockroot.swf");<br />

for (i in _root) {<br />

trace(" "+i+" -> "+_root[i]);<br />

}<br />

trace("");<br />

The lockroot.swf file has _lockroot applied to it, <strong>and</strong> nolockroot.swf does not. After the files<br />

are loaded, each file dumps variables from their _root scopes. Place the following<br />

ActionScript on the main Timeline of a FLA document:<br />

this.createEmptyMovieClip("lockroot_mc", this.getNextHighestDepth());<br />

lockroot_mc.loadMovie("lockroot.swf");<br />

this.createEmptyMovieClip("nolockroot_mc", this.getNextHighestDepth());<br />

nolockroot_mc.loadMovie("nolockroot.swf");<br />

function dumpRoot() {<br />

trace("from current SWF file");<br />

for (i in _root) {<br />

trace(" "+i+" -> "+_root[i]);<br />

}<br />

trace("");<br />

}<br />

dumpRoot();<br />

MovieClip 447

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!