Your problem lies with the understanding of the loader class. Firstly, you need a different loader for every image, using one loader will ultimately result in the loader's content being the last image loaded. Secondly, you are trying to add the same loader to it's container twice, so it looks like it only added one loader, but the truth is, it added the same loader twice! Help: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Loader.html
Bottom line is, use separate loaders for separate images. Hope it helps, Marton
this is how i would do it:
public class Model extends EventDispatcher {
var _setCartes:Array;
public function Model(target:Stage){
_setCartes = new Array();
ImportImg();
}
public function ImportImg():void{
for (var i:int = 0; i < 13; i++)
{
var imgcontainer:Loader = new Loader(); //create a new loader for every iteration
imgcontainer.load(new URLRequest("img/" + i + ".png"));
_setCartes.push(imgcontainer);
trace(_setCartes);
}
}
public function get setcartes():Array {
return _setCartes;
}
}
Keep in mind that the loaders will need time to load their images, the png-s will not be available right away. To avoid this, use this for every loader to check if they are finished.
myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, myCompleteHandler);
One thing i use is keeping track of the number of images needed to be loaded, subtract one for each finished loader, and declare loading finished when this number reaches zero.