Skip to main content
Known Participant
June 19, 2009
Answered

Preloader for multiple external images

  • June 19, 2009
  • 2 replies
  • 2561 views

Hi,

    I'm currently trying to solve this issue.

I'm creating a 360 turn by importing .png files into each movie clip. I wanted the preloader bar to increase in size as each one loads.

Once the preloader is completed on frame one, I have it go and stop on frame 2, but there is a blank screen for a view seconds. I think the images were still loading after the preloader was completed.

I have tried the fucntion getBytesTotal and getBytesLoaded, but did not work too well.

here is the sample of the code:

this.onEnterFrame =function()

{

preloader._alpha=100;  //Preloader

done=0;

t=0;

for (i=0;i<24;i++)

{

this["CAR_BASE_"+(i+1)].loadMovie("img/car_"+(i+1)+".png");

completed=((i+1)/24)*100;

preloader._xscale=completed;

}

if(completed==100){

gotoAndStop(2);

preloader._alpha=0;

this.onEnterFrame=null;

}

}

This topic has been closed for replies.
Correct answer kglad

I figured it out.

it suppose to be

          mcl.addListener(lo);

Thanks for the help again...


you're welcome.

2 replies

kglad
Community Expert
Community Expert
June 19, 2009

no, you won't load sequentially using a for-loop.

for example, you can't determine which image will load first and which will load last and, in general, you can't determine the order in which they load.

to load sequentially, use something like:

var mcl:MovieClipLoader=new MovieClipLoader();

var lo:Object=new Object();

lo.onLoadInit=function(target:MovieClip){

i++;

if(i<24){

loadF();

} else {

preloader._alpha=0;

gotoAndStop(2);

}

}

lo.onLoadProgress=function(target:MovieClip,bl:Number,bt:Number){

preloader._xscale = i/24+bl/(bt*24);

}

mcl.addEventListener(lo);

preloader._alpha=100;  //Preloader

var i:Number=0;

loadF();

function loadF(){

mcl.loadClip("img/car_"+(i+1)+".png",this["CAR_BASE_"+(i+1)]);

}

Known Participant
June 19, 2009

Thank you for the help.

I'm having one issue with the code.

mcl.addEventListener(lo);

I'm getting a compiler error that says "There is no method with the name 'addEventListener'".

Thanks,

Known Participant
June 19, 2009

I figured it out.

it suppose to be

          mcl.addListener(lo);

Thanks for the help again...

kglad
Community Expert
Community Expert
June 19, 2009

your code isn't preloading anything.  it's just checking the progress of your for-loop and that's not helpful.

you should not use a for-loop to load your images but load them sequentially.  you should also use the moviecliploader class to load your images and use its listeners onLoadProgress method.

Known Participant
June 19, 2009

How would i load them sequentially? Isn't what this for loop is doing? I'm loading in particular number of images of a car at different angles to create a 360 turn.

How would I use the movieClipLoader class for loading all of the images at once?

Thanks in advance.