Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>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: <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Loader.html" rel="nofollow">http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Loader.html</a></p> <p>Bottom line is, use separate loaders for separate images. Hope it helps, Marton</p> <p>this is how i would do it:</p> <pre><code>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 &lt; 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; } } </code></pre> <p>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. </p> <pre><code>myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, myCompleteHandler); </code></pre> <p>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.</p>
    singulars
    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.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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