0
votes

I can't figure out how to download all array(~10 pic) of images and then use them on screen. The problem is that in order not to weight the server, the pictures should be downloaded one time.

Now I load images like this: [code specially without the array just for example]

    var shirt1 = String("https://static.topsport.lt/sites/all/themes/topsport2/files/images/marskineliai_png/215.png");
    var img1Request:URLRequest = new URLRequest(shirt1);
    var img1Loader:Loader = new Loader();
    img1Loader.load(img1Request);
    myMovieClip.removeChildAt(0);
    myMovieClip.addChild(img1Loader);

I'm thinking about somehow in one flash keyframe as3 code load all images, and in second add load images to screen.

p.s. I add and remove array of Child's for the same movieclip symbol.

[edit] Here's that I try to compile:

FRAME 1

    function startLoad(e:Event = null):void {

        var marsk1 = String("https://static.topsport.lt/sites/all/themes/topsport2/files/images/marskineliai_png/215.png");
        var img1Request:URLRequest = new URLRequest(marsk1);
        var img1Loader:Loader = new Loader();
        img1Loader.load(img1Request);
        myMovieClip.removeChildAt(0);
        if(_2 != null){

        myMovieClip.smoothing = true;}

        //myMovieClip.addChild(img1Loader).addEventListener(Event.COMPLETE, startLoad);

        function achild(){
            myMovieClip.addChild(img1Loader);
        }
    }

FRAME 2

    achild().addEventListener(Event.COMPLETE, startLoad);

I tried to apply my situation to Andrey Popov suggestion. Can I import the function from the previous frame? Because I'am trying to do it and I get method not found

2

2 Answers

0
votes

You need to use addEventListener, and wait until the loading is finished. Then start a new one. Something like this:

var currentImage:uint = 0;

function startLoad(e:Event = null):void {
    if (currentImage == 5) {
        // we are all done
        return;
    }

    var loader:Loader = new Loader();
    // loader specific stuff..
    loader.contentLoaderInfo.addEventListener(Event.COMPLETE, startLoad);
    currentImage++;
}

This is a rough pseudo code but the idea is simple - wait for a loader to load, then load new image.

0
votes

I've solved the problem between frame actionscript connection by taking

var img1Loader:Loader = new Loader();

and putting it in front of the function. That's how the loader can be accessed on the other frame.