Reputation:
just a quick question reguarding how to make a preloader animate backwards. So the bar decreases in width as the load number gets larger.
Here's my code
onClipEvent (enterFrame) {
loading = _root.getBytesLoaded();
total = _root.getBytesTotal();
if (percent == undefined) percent = 0;
percent -= (percent-((loading/total)*100))*.25;
per = int(percent);
percentage = per+"%";
loadBar._width = per*9.70;
if (percent>99) {
_root.gotoAndStop(2);
}
}
Many thanks,
Matt
Upvotes: 0
Views: 1760
Reputation: 345
I think this is simpler:
onClipEvent (load) {
onEnterFrame = function () {
loading = _root.getBytesLoaded();
total = _root.getBytesTotal();
percent = Number(loading/total);
this._xscale = (1-percent)*100;
trace(percent);
if (percent>=1) {
//_root.gotoAndStop(2);
delete (onEnterFrame);
}
};
}
And it will stop after conditon (percent>=1) become true.
Upvotes: 2
Reputation: 1365
change the line
loadBar._width = per*9.70;
into
loadBar._width = (100 -per)*9.70;
is a quick and dirty way to do it
Upvotes: 1