multible swf/jpg load via MovieClipLoader getTotalbytes ?
Hej Alle, jeg har gang i at lave en multiple loader, som den er nu håndterer den at loade filer i en række(en ad gangen), men nu vil jeg gerne få en progress bar til alle de filer som jeg har lagt i min array. Det vil sige få totalBytes på alle filerne i arrayen. Er der nogen som kender en metode til at få det frem uden at loade selve swf/jpg-en..as script:
//Preeloader script
// first set of listeners
var my_movieClipLoader = new MovieClipLoader();
// Define -------------------
myLoadListener = new Object();
myLoadListener.onLoadStart = function(target_mc) {
var loadProgress = my_movieClipLoader.getProgress(target_mc);
movieArray[0][0].onLoadStartFunction();
};
myLoadListener.onLoadProgress = function(target_mc, loadedBytes, totalBytes) {
//Propertie skal gøres generic
//myLoaderProgress.percentsLoaded = Math.round(loadedBytes/totalBytes*100);
//
movieArray[0][0].percentsLoaded = Math.round(loadedBytes/totalBytes*100);
};
myLoadListener.onLoadComplete = function(target_mc) {
movieArray[0][0].onLoadCompleteFunction();
movieArray.splice([0], 1);
if (movieArray.length !== 0) {
my_movieClipLoader.loadClip(movieArray[0][1], movieArray[0][2]);
}
if (movieArray.length == 0 && myLoaderProgress.percentsLoaded==100) {
//Important for CPU usage
trace("All finished")
delete movieArray[0][0].onEnterFrame;
movieArray[0][0].percentsLoaded = 100;
}
};
myLoadListener.onLoadInit = function(target_mc) {
movieArray[0][0].onLoadInitFunction();
//WHEN LOADING FINISHES WHAT SHOULD HAPPEN TO MC
//trace("Movie clip = "+target_mc+" is now initialized");
// you can now do any setupmy_movieClipLoader.onEnterFrame required, for example:
//target_mc._width = 100;
//target_mc._width = 100;
};
myLoadListener.onLoadError = function(target_mc, errorCode) {
trace("*********First my_mcl instance*********");
trace("ERROR CODE = "+errorCode);
trace("Your load failed on movie clip = "+target_mc+"\n");
};
// Listener addet to my_mcl
my_movieClipLoader.addListener(myLoadListener);
//CREATE THE LOADING ARRAY
movieArray = new Array[[]]();
//
function SendToMovieLoader(progressMovieInstance, movieUrl, movieTargetInstance, movieDescription) {
movieArray.push([progressMovieInstance, movieUrl, movieTargetInstance, movieDescription]);
}
//Start the loading sequence
function StartMovieLoader() {
my_movieClipLoader.loadClip(movieArray[0][1], movieArray[0][2]);
SeeTotalKb();
}
//Denne function virker så ikke, men det er den som jeg mangler
function SeeTotalKb(){
for (i=0; i<movieArray.length; i++){
totalKB += movieArray[i][1].getBytesTotal()
trace(movieArray[i][1]+" :movieArray[i][1]")
trace(totalKB+" :totalKB");
}
}
////////////////////////////////////////////////////////////////
.fla
1.frame:
#include "Preloader.as"
//USER PART
this.createEmptyMovieClip("mc_loaded", 2);
this.createEmptyMovieClip("mc_loaded2", 3);
this.createEmptyMovieClip("mc_loaded3", 4);
this.createEmptyMovieClip("mc_loaded4", 5);
//
SendToMovieLoader(progress1,"loadMC3.swf", mc_loaded);
SendToMovieLoader(progress2,"loadMC3.swf", mc_loaded2);
SendToMovieLoader(progress3,"loadMC3.swf", mc_loaded3);
SendToMovieLoader(progress1,"loadMC3.swf", mc_loaded4);
//IMPORTANT TO START THE SEQUNCE
StartMovieLoader();
/////////////////////////////////////////////////////////////////
Selve grafiken
f.eks.
instance.progress1
1.frame:
function onLoadStartFunction(){
trace("Start loading movieClip")
}
function onLoadCompleteFuncton(){
trace("Complete loading movieClip")
}
function onLoadInitFunction(){
trace("Init movieClip")
}
onEnterFrame = function () {
bar_mc._yscale = percentsLoaded
};
////////////////////////////////////////////////////////////////
Håber i kan forstå hvad jeg mener.
mvh