PDA

View Full Version : How can I create a percentage bar loader that doesn't jump.


dtrace
04-29-2004, 04:34 PM
Here is the issue.

I'm using a loader that gets bytes loaded and then based on that plays the loader. But the result is that the loader jumps and doesn't animate in a smooth way the way I want it to.

The animation is simple, it's just a red bar of color that gets bigger. HOw can I make a percentage bar loader that doesn't jump?

Thanks, I appreciate the help.

avatar
04-30-2004, 09:20 AM
You need to use some kind of scripted transformation. Check the tuts/movies on this site. Or use this code...

Place this in the root of your movie
sk = 0.2;
_global.Ftransform = function(targ, width, height) {
targ.createEmptyMovieClip("transform", depth++);
targ.transform.onEnterFrame = function() {
var dwidth = width-targ._width;
var dheight = height-targ._height;
targ._width += (dwidth*sk);
targ._height += (dheight*sk);
if ((Math.round(dwidth+targ._width) == width) && (Math.round(dheight+targ._height) == height)) {
targ._width = width;
targ._height = height;
targ.transform.onEnterFrame = undefined;
targ.transform.removeMovieClip();
}
};
};

Above code takes care of the smooth tranformation

Place this on your loader MC

onClipEvent (enterFrame) {
if (_root.getBytesLoaded()<_root.getBytesTotal()) {
percent = 100*(_root.getBytesLoaded()/_root.getBytesTotal());
Ftransform(_root.mc_loader, percent, 10);
}
}

This will trigger the transformation code

Hope this is what you are looking for