PDA

View Full Version : Help: preloader movieclip


ryatsuix88
04-02-2005, 09:15 AM
Hello all,
I made a preloader movieclip. it's 150 frames long and it's animation are where small square boxes getting filled up. I can get the preloader to work, however, sometimes it won't load til' the end (reach the end of the animation) and would just jump right on to frame 2 after it's done loading.
Is there any code that i can put it so that the animation will move with however % the total had loaded so that THE ENTIRE preloader animation can complete and then start playing the main flash movie. I had also included the file if anyone would like to take a look at it.
http://www.personal.psu.edu/srt141/index3.zip
Thank you very much in advance.

Ryan

gvDan
05-15-2005, 12:32 AM
Use gotoAndPlay() and some sort of frame marker. Also, you can use an easing function so that it's forced to run somewhat smoothly.

base the load on the position of the animation. first, make this whole thing 2 seperate SWF's, so that the animation acts as a preloader, and you load the rest into the preloading SWF. very simple.
Second, we'll set _visible of the container to false, and then toggle it when the animation finishes...


assuming you have a movieclip called "animation", for instance:

//----permanent variables to track progress
bytesL;
bytesT;
//----variable to act as a frame marker
frameNum = 1;
createEmptyMovieClip("holder", 1);
holder._visible = false;
my_mcl = new MovieClipLoader();
myListener = new Object();
my_mcl.addListener(myListener);
my_mcl.loadClip("blah.swf", _root.holder);
myListener.onLoadProgress = function(target_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number) {
bytesL = bytesLoaded;
bytesT = bytesTotal;
}
_root.animation.onEnterFrame = function(){
frameNum += (bytesL/bytesT*150 - frameNum)/10;
this.gotoAndPlay(Math.ceil(frameNum));
if(bytesL/bytesT==1){
delete(this.onEnterFrame);
_root.holder._visible = true;
}
}