I have a preloader that works with a timeline animation and the original numbers were to count the load up for the file size. I tried to convert it to a percentage meter and for some reason the numbers just display as numbers.
The code is below and I am drawing blanks now, can anyone see where things are getting messed up?
code on the mc
code on the first frame in the mc for the timeline animationCode:onClipEvent (load) { if (_parent.getBytesTotal() == _root.getBytesLoaded()) { quickPlay = true; } else { preLoad = (_root.getBytesTotal() * 0.95); //percent to preload } _root.stop(); } onClipEvent (enterFrame) { gotoAndStop(loadedIndicatorFrame()); if (quickPlay == true) { //quickly play the anim if (_currentframe == _totalframes) { _root.gotoAndPlay("project"); } } else { //wait for the preload if (_root.getBytesLoaded() >= preLoad) { _root.gotoAndPlay("project"); } } }
I tried to change over the "kb" to "%" and that worked alright but the numbers did not go from 0 to 100.Code:lastFrame = 1; function loadedIndicatorFrame() { var newFrame = int((_root.getBytesLoaded() / _root.getBytesTotal()) * 65) + 2; if (newFrame - lastFrame > 4) { //too far lastFrame += 4; loadedText = int(_root.getBytesTotal() / 1024 * (lastFrame - 2) / 65) + "kb of " + int(_root.getBytesTotal() / 1024) + "kb"; } else if (newFrame - lastFrame > 0) { //normal move lastFrame++; loadedText = int(_root.getBytesLoaded() / 1024) + "kb of " + int(_root.getBytesTotal() / 1024) + "kb"; } else { //update the text only loadedText = int(_root.getBytesLoaded() / 1024) + "kb of " + int(_root.getBytesTotal() / 1024) + "kb"; } return lastFrame; }
Any help or direction on what is going wrong would be great.



Reply With Quote
Bookmarks