actionscript 3 - In AS3 calling loadBytes 2 times in sequence wont work -


while code pretty big , fragmented on many files show here, boils down this:

i have function this:

var loadedscript:loader; function load():void{     loadedscript = new loader();     // loadedscript initilized somewhere , other stuff     loadedscript.loadbytes(bytes, context);     loadedscript.contentloaderinfo.addeventlistener(event.complete, scriptloaded, false, 0, true); } 

when call function 2 times in row in such way called 2. time before loadedscript.loadbytes(bytes, context); 1. time can finish, "scriptloaded" method called 2. time, not 1. time

so, intentional behaivor loadedscript.loadbytes(bytes, context); method, or bug, cann bypass somehow?

you ofcourse create loader-queue, this:

var queue:array = new array(); function load(bytestoload:*):void {     queue.push(bytestoload);     processqueue(); }  function processqueue():void {     //check if items on queue     if (queue.length > 0) {         //create loader         var ldr:loader = new loader();         //add event loading complete         ldr.contentloaderinfo.addeventlistener(event.complete, scriptloaded, false, 0, true);         //load bytes (get first item queue, contains bytes load)         ldr.loadbytes(queue.shift(), context);     } }  function scriptloaded():void {      //do stuff       //process next item in queue      processqueue(); } 

Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -