PDA

View Full Version : Dynamically populating an array SWFs



veniceflasher
October 31st, 2008, 01:33 PM
I'm having a bunch of trouble using a loader to populate an array. I'm trying to use one loader contained in a loop along with the push method. Is this possible to use a single loader or do I need to create an array of loaders as well. With the code I'm using now all the positions in the array end up showing the last SWF that I call.

Here's the code:

for(var i:int=1; i <= 4; i++){

caseName = "case" + _caseCounter + ".swf";
trace(caseName);
_caseCounter++;

var panelLoader:Loader = new Loader();
panelLoader.load(new URLRequest("casefolder/" + caseName));
panelLoader.contentLoaderInfo.addEventListener(Eve nt.COMPLETE, loaded, false, 0, true);

function loaded(evt:Event):void {

casePanel.push(panelLoader.content);
trace("pushed");

}



}

Magik5
October 31st, 2008, 02:02 PM
try breaking out

function loaded(evt:Event):void {

casePanel.push(panelLoader.content);
trace("pushed");

}

from the for loop =]

veniceflasher
October 31st, 2008, 02:33 PM
thanks! i'll give that a try.

veniceflasher
October 31st, 2008, 06:19 PM
It didn't solve the problem. I gonna try and create an array of loaders.

veniceflasher
October 31st, 2008, 06:20 PM
try breaking out

function loaded(evt:Event):void {

casePanel.push(panelLoader.content);
trace("pushed");

}

from the for loop =]

That didn't solve it. I'm gonna try creating an array of loaders.

Thanks!

veniceflasher
November 1st, 2008, 03:18 PM
That didn't solve it. I'm gonna try creating an array of loaders.

Thanks!

for(var i:int=1; i <= 4; i++){

caseName = "case" + _caseCounter + ".swf";
_caseCounter++;

var mLoader:Loader = new Loader();
var mRequest:URLRequest = new URLRequest("casefolder/" + caseName);
mLoader.contentLoaderInfo.addEventListener(Event.C OMPLETE, onCompleteHandler);
//mLoader.contentLoaderInfo.addEventListener(Progres sEvent.PROGRESS, onProgressHandler);
mLoader.load(mRequest);

}

//}

function onCompleteHandler(loadEvent:Event) {

casePanel[panelPusher] = loadEvent.currentTarget.content;
panelPusher++;

}