Groups | Blog | Home
all groups > flash actionscript > july 2006 >

flash actionscript : Time Line Preloader?


infoVac
7/16/2006 5:03:29 PM
This is my problem. I am trying to make a preloader that plays a movie clip
Time Line at the speed of which the bytes are loaded. My knowledge of the code
is not the best. help would be greatly appreciated.
kglad
7/16/2006 5:18:41 PM
you can start with:



MovieClip.prototype.playF = function(m, n, fps) {
function playF2(mc) {
if (mc.m<mc.n) {
mc.nextFrame();
} else if (mc.m>mc.n) {
mc.prevFrame();
}
if (mc._currentframe == mc.n) {
clearInterval(mc.int);
}
updateAfterEvent();
}
this.m = m;
this.n = n;
this.fps = fps;
this.gotoAndStop(this.m);
clearInterval(this.int);
this.int = setInterval(playF2, 1000/this.fps, this);
};
preloadI = setInterval(preloadF, 100, targetMC);
function preloadF(mc) {
bl = targetMC.getBytesLoaded();
bt = targetMC.getBytesTotal();
if (previouslyLoadedBytes) {
dlSpeed = (bl-previouslyLoadedBytes)/(getTimer()-previousTime);
// you might want to use some factor of dlSpeed
yourMCToPlay.playF(1, yourMCToPlay._totalframes, dlSpeed);
}
previousTime = getTimer();
previouslyLoadedBytes = bl;
if (bl>12 && bl>=bt) {
clearInterval(preloadI);
}
}
AddThis Social Bookmark Button