Groups | Blog | Home
all groups > flash actionscript > january 2005 >

flash actionscript : Loading a queue



adamjbrown
1/6/2005 11:06:56 PM
Does anyone know if there is a way to track the progress of a group or queue of
images and sounds. I am dynamically loading sounds and images (over 500 of
each) and have no way to track the progress. Any help would be appreciated.
NSurveyor
1/6/2005 11:24:31 PM
Load all your sounds and images into one movieclip. Then, you can look at
yourMC.getBytesLoaded() and yourMC.getBytesTotal(); For example, do this:

createEmptyMovieClip('thestuff',1);
thestuff.mySound = new Sound();
thestuff.mySound.loadSound('someFile.wav');
thestuff.createEmptyMovieClip('image1');
thestuff.image1.loadMovie('image_1.jpg');
thestuff.onEnterFrame = function(){
trace(String(this.getBytesLoaded()/this.getBytesTotal()*100)+'% Complete');
if(this.getBytesLoaded()==this.getBytesTotal()&&this.getBytesTotal()!=0){
delete this.onEnterFrame
}
}
NSurveyor
1/6/2005 11:29:31 PM
Or another way:

filesLoading = new Array();
mySound = new Sound();
mySound.loadSound('someFile.wav');
createEmptyMovieClip('image1');
image1.loadMovie('image_1.jpg');
filesLoading.push(mySound);
filesLoading.push(image1);
getProgress(filesLoading);
setInterval(getProgress,1000,filesLoading);
function getProgress(someArray){
tload = 0;
ttotal = 0;
for(x=0;x<someArray.length;x++){
tload+=someArray[x].getBytesLoaded();
ttotal+=someArray[x].getBytesTotal();
}
info = new Array(tload,ttotal);
trace(''+tload+'/'+ttotal);
return info;
}
AddThis Social Bookmark Button