This will do it all on the fly.... (in both examples, you'll need to upload the files to your server to test them...as you can't test preloaders locally)
Code:
loadMovieNum("design2.swf", 1);
this.createEmptyMovieClip("progressBar_mc", 2);
progressBar_mc.createEmptyMovieClip("bar_mc", 3);
progressBar_mc.createEmptyMovieClip("stroke_mc", 4);
with (progressBar_mc.stroke_mc) {
lineStyle(1, 0xFFFFFF);
moveTo(0, 0);
lineTo(100, 0);
lineTo(100, 10);
lineTo(0, 10);
lineTo(0, 0);
}
with (progressBar_mc.bar_mc) {
beginFill(0xCCCCCC, 100);
moveTo(0, 0);
lineTo(100, 0);
lineTo(100, 10);
lineTo(0, 10);
lineTo(0, 0);
endFill();
_xscale = 0;
}
progressBar_mc._x = 20;
progressBar_mc._y = 20;
progressBar_mc.onEnterFrame = function () {
loaded = _level1.getBytesLoaded()/1000;
total = _level1.getBytesTotal()/1000;
percent = Math.ceil(loaded/total)*100;
this.bar_mc._xscale = percent;
if (percent == 100) {
delete this.onEnterFrame;
this.removeMovieClip();
}
};
or this will work as well. create your preloader mc with the first frame empty... just put a stop() on it. Then on the 2nd frame, create a loadBar movieclip with the instance name loadBar and a dynamic textfield with the instance name display_txt. Then place this code on the 2nd frame:
Code:
this.onEnterFrame = function(){
percent = (_level1.getBytesLoaded()/_level1.getBytesTotal())*100;
if(!isNaN(percent)){
if (percent == 0) {
display_txt.text = "";
} else {
display_txt.text = Math.ceil(percent) + "% Loaded";
}
loadBar._xscale = percent;
_level1.stop();
}
if(percent == 100){
this.gotoAndStop(1);
delete this.onEnterFrame;
_level1.play();
}
}
stop();
// then on your main timeline, you'd load the movie and call the preloader like this:
loadMovieNum("design2.swf", 1);
preloader.gotoAndStop(2);