Note that there are some explanatory texts on larger screens.

plurals
  1. POAS3 Event Architecture Issue
    primarykey
    data
    text
    <p>Before calling the function <code>addNodeFilled()</code> that uses an external bitmap file as a fill I must load the bitmap file in flash player using Loader class and wait for the loader to finish loading and fire <code>Event.COMPLETE</code> and execute the corresponding event handler <code>onComplete()</code>. To ensure this I have a while loop to wait for completion of loading in <code>addNodeFilled()</code>, but when running the program the program esp the loop goes on infinitely which means in flash the event handler is executed synchronously with the main sequence and can't execute until <code>addNodeFilled()</code> ends. Usually the code in <code>addNodeFilled()</code> is placed inside <code>onComplete</code> event handler but I am unable to do that and need to call <code>addNodeFilled()</code> whenever I wish but check for load completion, how can I do that?</p> <pre><code>var stitch:BitmapData = new BitmapData(16, 16); var loaderStatus:String = "busy"; var loader:Loader = new Loader(); loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete); loader.load(new URLRequest("file:///E:/Projects/FlashDevelop/Terracotta/assets/Stripe.jpg")); addNodeFilled(100, 100); //function definitions=============================================== function onComplete(event:Event):void { stitch = event.target.content.bitmapData; loaderStatus = "loaded"; } //onComplete function addNodeFilled(posx:Number, posy:Number):void { while(loaderStatus != "loaded") { trace("waiting for loader"); } var grid:Rectangle = new Rectangle(5, 5, 5, 5); var nodeDecal:Sprite = new Sprite(); nodeDecal.graphics.beginBitmapFill(stitch, null, true, true); nodeDecal.graphics.drawRoundRectComplex(posx, posy, 80, 16, 0, 0, 4, 4); nodeDecal.scale9Grid = grid; addChild(nodeDecal); } //addNodeFilled </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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