<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 &#39;as needed&#39; means the first time the definition is encountered lexically</div>
<div>in the app file(s). &nbsp;For example</div><div><br></div><br clear="all"><div>MyClass.as:</div><div>package {</div><div>&nbsp;&nbsp;</div><div>&nbsp;&nbsp; &nbsp;import flash.display.*;</div><div>&nbsp;&nbsp; &nbsp;import flash.events.*;</div><div><br></div><div>
&nbsp;&nbsp; &nbsp;public class MyClass extends Sprite {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;public function MyClass () {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;trace(&#39;starting MyClass&#39;);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;trace(&#39;fooC&#39;, fooC);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;trace(&#39;fooB&#39;, fooB);</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;trace(&#39;fooA&#39;, fooA);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;trace(&#39;fooCount&#39;, fooCount);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;}</div><div><br></div><div>&nbsp;&nbsp; &nbsp;}</div><div>}</div><div><br></div><div><br></div><div><br></div><div>
<br></div><div>fooA.as:</div><div>&nbsp;&nbsp; &nbsp;package {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;public var fooA:int = fooCount.inc();</div><div>&nbsp;&nbsp; &nbsp; }</div><div><br></div><div>fooB.as:</div><div>&nbsp;&nbsp; &nbsp;package {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>public var fooB = fooCount.inc();</div>
<div>&nbsp;&nbsp; &nbsp;}</div><div><br></div><div>fooC.as:</div><div>&nbsp;&nbsp; &nbsp;package {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>public var fooC = fooCount.inc();</div><div>&nbsp;&nbsp; &nbsp;}</div><div><br></div><div>fooCount.as:</div>
<div>&nbsp;&nbsp; package {</div><div>&nbsp;&nbsp; &nbsp; &nbsp; public class fooCount {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp; public static var val:int = 0;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp; public static function inc () {</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp; &nbsp; &nbsp; return val++;</div><div><span class="Apple-tab-span" style="white-space:pre">        </span> &nbsp; }</div><div>&nbsp;&nbsp; &nbsp; &nbsp; }</div><div>&nbsp;&nbsp; }</div><div><br></div><div>
<br></div><div>In the code above, the app executes as:</div><div>&nbsp;&nbsp; &nbsp; [trace] starting MyClass</div><div>&nbsp;&nbsp; &nbsp; [trace] fooC 0</div><div>&nbsp;&nbsp; &nbsp; [trace] fooB 1</div><div>&nbsp;&nbsp; &nbsp; [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>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;trace(&#39;starting MyClass&#39;);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;trace(&#39;fooC&#39;, fooC);</div><div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;trace(&#39;fooB&#39;, fooB);</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;trace(&#39;fooA&#39;, fooA);</div><div><br></div><div>executes as:</div><div>&nbsp;&nbsp; &nbsp;[trace] starting MyClass</div><div>&nbsp;&nbsp; &nbsp;[trace] fooA 0</div><div>&nbsp;&nbsp; &nbsp;[trace] fooB 1</div><div>&nbsp;&nbsp; &nbsp;[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&nbsp;</div>
<div>which touches all the LFC classes and globals &nbsp;in the order we want them to execute.</div><div><br></div><div>BTW, I tried writing the globals classes as files&nbsp;</div><div><br></div><div>package {</div><div>&nbsp;&nbsp;var fooCount:int = 0;</div>
<div>}</div><div><br></div><div>package {</div><div>&nbsp;&nbsp; &nbsp;public var fooA:int = fooCount++;</div><div>}</div><div><br></div><div>package {</div><div>&nbsp;&nbsp; &nbsp;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>