Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Ha!</p> <p>I was too desperate, solution found.</p> <p>It appears, that <strong>CompiledESC cannot be used in the same frame</strong> where it was <strong>created</strong>.</p> <hr> <p>So in the other words, something like this <strong>won't work</strong>:</p> <pre><code>public function compile(code: String) : ByteArray { var compiler:CompiledESC = new CompiledESC(); return compiler.eval(code); } </code></pre> <hr> <p>But <strong>following code will work</strong> (application loads, initializes CompileESC and then user clicks the RUN! button, which happens in different frame from the one where CompileESC was created):</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" &gt; &lt;fx:Script&gt; &lt;![CDATA[ import com.hurlant.eval.CompiledESC; import mx.events.FlexEvent; private var compiler:CompiledESC = new CompiledESC(); protected function button1_clickHandler(event:MouseEvent):void { compiler.eval("trace(\"hello!\")"); } ]]&gt; &lt;/fx:Script&gt; &lt;mx:Button label="RUN!" click="button1_clickHandler(event)" /&gt; &lt;/s:Application&gt; </code></pre> <hr> <p>I do not know exactly why, but I suspect it has something to do with the way Flash is loading its bytecode. When you try to insert some code into VM and use it in the same frame you're asking for troubles because your code has just not been loaded yet. You have to "yield" the thread and wait for another frame, somewhere in-between Tamarin ESC code gets loaded.</p> <p>Note that the same applies for compiled code being loaded via ByteBuffer by you! Whenever you do something like</p> <pre><code>ByteLoader.load(compiler.eval(myAS3Code)); </code></pre> <p>Do not expect that <em>myAS3Code</em> will be executed right away. Again, the code will be loaded whenever you "yield" the thread and let VM to truly load your code.</p> <p>Hope this helps someone in the same situation.</p> <p>Best, Jakub</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload