views:

32

answers:

1

I load many images simultaneously with different Loader class. When loaded I add content of loaders to the movieclips which are child of some other movieclip which is child other... I check that images are loaded addChild method is called, but loaded images cannot be seen on the screen.

Actually, sometimes images can be seen, but sometimes cannot be seen.

Do I need to rerender some DisplayObject? Something similar...

A: 
import flash.display.Loader;
import flash.display.Sprite;
import flash.net.URLRequest;

public class Image {

    private var _loader:Loader;

    public function Image(src:String) {
        _loader = new Loader();
        _loader.load(new URLRequest(src));
    }

    public function get loader():Loader {
        return _loader;
    }
}

Then when you load the images:

public function loadImages(images:XML):void {
    var _i:Image;
    for each(var image:XML in images) {
        _i = new Image(image.src);
        _i.loader.contentLoaderInfo.addEventListener(Event.COMPLETE, addImage);
    }
}

private function addImage(e:Event):void {
    parent.addChild(e.target.content);
}
N. Lucas
Thank you for your extensive help. I do not know how, but today my code, suddenly, started to work. I am suspicious, I might come back here and ask again.I also have a question. I do not add loader as a child, but I get its content as a DisplayObject and add it as a child. Does it make any difference?
Oki
addChild(Loader) and addChild(Loader.content) works just the same.
N. Lucas