Forum Moderators: open

Message Too Old, No Replies

preloader problem - preload images from directory

Flash MX

         

T_Ma

12:58 am on Mar 11, 2008 (gmt 0)

10+ Year Member



I want to make a preloader which can preload images from directory and the main scene will only run after all images are completely loaded.

Using the following codes I found the files are loaded correctly but the Gbytesloaded=lod+lodmain codes have not correctly included the size of the images. That means the main scene is run BEFORE the pics are fully loaded. Pls help! Thanks! (I use Flash MX.)

code in the 1st frame of the preloader:
a=a+1;
if(a==1) {

picno=1;
duplicateMovieClip(blankimg, "aa0"+picno, 3);
loadMovie("image/pic0"+picno+".jpg","aa0"+picno);

picno=2;
duplicateMovieClip(blankimg, "aa0"+picno, 2);
loadMovie("image/pic0"+picno+".jpg","aa0"+picno);

picno=3;
duplicateMovieClip(blankimg, "aa0"+picno, 1);
loadMovie("image/pic0"+picno+".jpg","aa0"+picno);
}

preload();

function preload(){
lod1 = aa01.getBytesLoaded();
tot1 = aa01.getBytesTotal();
lod2 = aa02.getBytesLoaded();
tot2 = aa02.getBytesTotal();
lod3 = aa03.getBytesLoaded();
tot3 = aa03.getBytesTotal();

lod=lod1+lod2+lod3;
tot=tot1+tot2+tot3;

lodmain=getbytesloaded();
totmain=getbytestotal();
Gbytesloaded=lod+lodmain;
Gbytestotal=tot+totmain;
load_percent=int(Gbytesloaded/Gbytestotal*100);
if (Gbytesloaded >= Gbytestotal) {
gotoAndPlay ("main", 1);

};
}