Hi, im having problems with the following code:
for (var i:Number=0; i<numFaces;i++){
var faceLoader:Loader = new Loader();
faceLoader.contentLoaderInfo.addEventListener( Event.INIT,
function(fle:Event){
LoadCara(i,faceLoader);
trace("LoadCara:" + i.toString());
} );
}
function LoadCara(index:int,loader:Loader){
if(index == 0)
{
trace("cara1:" + index.toString());
cara1.removeChildAt(0);
cara1.addChild(loader);
}
else if(index == 1)
{
cara2.removeChildAt(0);
cara2.addChild(loader);
}}
The problem is that im sending the variable i to the function LoadCara on every iteration, and its always called with the last value of i. I would like this function to be called with the appropiate index.
Hope I explain myself, thanks in advance.