View Full Version : Percentage Text not Updating (preloader)
pHrOsT
06-20-2005, 07:45 PM
Hey all, I got a preloader that works fine with a working loadbar and a dynamic text box that appears to get the correct input but the problem is it only updates once...even while the loadbar continues to grow, and ideas on what could be causing this? thanks
onEnterFrame = function() {
totalBytes = _parent.getBytesTotal();
loadedBytes = _parent.getBytesLoaded();
percent = Math.ceil((loadedBytes/totalBytes)*100);
gotoAndStop(percent);
info_txt.text = percent+" %";
if (percent>=100) {
_parent.gotoAndPlay(2);
}
}
by the way the text above is on an action layer in the preloader MC, 1 level under main timeline (movie is stopped on frame 1 until it completes loading which works fine)
Billystyx
06-21-2005, 12:45 PM
try adding a variable name to the text field (var1 for example), and using that variable name in your AS.
Does that work?
Dylan Marvin
06-21-2005, 05:09 PM
Call me old fashioned, but I still like using preloading code in the _root's first couple frames. You know, loop the first two frames untill it's loaded and move on. I know what you are doing is essentially the same thing, but referenced from a MC, I just find less hassles the more I use frame scripting for loaders for some reason. Also, Billystyx has a good point, always have a name for dynamic text.
pHrOsT
06-21-2005, 05:30 PM
That's a good idea Dylan, it would certainly keep things a little simpler, I'll keep it in mind. Billy I dont know whether you meant the var or the instance name for the dynamic textbox but I had already set the var in the textbox as "info_txt." However what you said gave me a spark of intuition...I remembered how from previous experienced even though Action Script 2.0 is so amazing with it's self inializing capabilities that it usually catches everything I figured an easy fix might just be to try and initialize info_txt as a String variable to begin with so there was no confusion...and POOF, the preloader magically works...very strange is the way of Flash. Here's the final code that does work (this sits on an action layer in the movieclip "preloader")
stop();
infotxt = String
onEnterFrame = function() {
totalBytes = _parent.getBytesTotal();
loadedBytes = _parent.getBytesLoaded();
percent = Math.ceil((loadedBytes/totalBytes)*100);
infotxt = percent+" %";
gotoAndStop(percent);
if (percent>=100) {
_parent.gotoAndPlay(2);
}
}
Thanks for the help guys!
vBulletin® v3.7.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.