<div dir="ltr"><div>I found that, as we had seen before, classes (hence, global defs) are linked in by the flex linker (compc) on an</div><div>as-needed basis, where 'as needed' means the first time the definition is encountered lexically</div>
<div>in the app file(s). For example</div><div><br></div><br clear="all"><div>MyClass.as:</div><div>package {</div><div> </div><div> import flash.display.*;</div><div> import flash.events.*;</div><div><br></div><div>
public class MyClass extends Sprite {</div><div> public function MyClass () {</div><div> trace('starting MyClass');</div><div> trace('fooC', fooC);</div><div> trace('fooB', fooB);</div>
<div> trace('fooA', fooA);</div><div> trace('fooCount', fooCount);</div><div> }</div><div><br></div><div> }</div><div>}</div><div><br></div><div><br></div><div><br></div><div>
<br></div><div>fooA.as:</div><div> package {</div><div> public var fooA:int = fooCount.inc();</div><div> }</div><div><br></div><div>fooB.as:</div><div> package {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>public var fooB = fooCount.inc();</div>
<div> }</div><div><br></div><div>fooC.as:</div><div> package {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>public var fooC = fooCount.inc();</div><div> }</div><div><br></div><div>fooCount.as:</div>
<div> package {</div><div> public class fooCount {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> public static var val:int = 0;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> public static function inc () {</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span> return val++;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> }</div><div> }</div><div> }</div><div><br></div><div>
<br></div><div>In the code above, the app executes as:</div><div> [trace] starting MyClass</div><div> [trace] fooC 0</div><div> [trace] fooB 1</div><div> [trace] fooA 2</div><div><br></div><div><br></div><div>
but if I change the code to refer to the globals in this order, the execution order changes to match</div><div> trace('starting MyClass');</div><div> trace('fooC', fooC);</div><div> trace('fooB', fooB);</div>
<div> trace('fooA', fooA);</div><div><br></div><div>executes as:</div><div> [trace] starting MyClass</div><div> [trace] fooA 0</div><div> [trace] fooB 1</div><div> [trace] fooC 2</div><div><br>
</div><div><br></div><div>So the classes are linked in based on where they first lexically occur in the app code being</div><div>compiled. So we are in somewhat good shape with regards to the order in which globals are being executed,</div>
<div>except since all our LFC code is in a .swc library, the code will get linked in an order dependent on the</div><div>app. So maybe we need to do like I started before, and have a function at the start of the app execution </div>
<div>which touches all the LFC classes and globals in the order we want them to execute.</div><div><br></div><div>BTW, I tried writing the globals classes as files </div><div><br></div><div>package {</div><div> var fooCount:int = 0;</div>
<div>}</div><div><br></div><div>package {</div><div> public var fooA:int = fooCount++;</div><div>}</div><div><br></div><div>package {</div><div> public var fooB:int = fooCount++;</div><div>}</div><div><br></div><div>
that compiles into library code, but gives a player verifier error when linked with the app.</div><div>I am filing a bug report on that to adobe.</div>-- <br>Henry Minsky<br>Software Architect<br><a href="mailto:hminsky@laszlosystems.com">hminsky@laszlosystems.com</a><br>
<br><br>
</div>