2/3Soul
10-23-2003, 05:31 PM
Hey everyone - I have been using previous versions of Flash for quite a while, but never really delved to deeply into the wonders of Actionscript....
My question is regarding some actionscript code that I obtained from one of the tutorials (http://www.actionscript.org/tutorials/beginner/Smooth_PreLoader/index.shtml) on this site a while ago...
Now that I have upgraded to MX 2004, it seems that if I publish the .swf file that contains this code, it doesn't work anymore, but if I change the 'Publish Settings...' to 'Actionscript 1.0', then it works.
The relevant code sits on the preloader movie itself:
onClipEvent (enterFrame) {
loading = _parent.getBytesLoaded();
total = _parent.getBytesTotal();
percent -= (percent-((loading/total)*100))*.25;
per = int(percent);
percentage = per+"%";
loadBar._width = per;
if (percent>99) {
_parent.gotoAndStop(2);
}
}
Now if I am looking at it right, the issue is with the fact that if a variable is previously undefined, Actionscript 2.0 evaluates it in a numerical context as "NaN" instead of "0", which screws everything up for the 'percent' variable.
Has anyone got any ideas for trying to fix this ? :confused:
Cheers!
My question is regarding some actionscript code that I obtained from one of the tutorials (http://www.actionscript.org/tutorials/beginner/Smooth_PreLoader/index.shtml) on this site a while ago...
Now that I have upgraded to MX 2004, it seems that if I publish the .swf file that contains this code, it doesn't work anymore, but if I change the 'Publish Settings...' to 'Actionscript 1.0', then it works.
The relevant code sits on the preloader movie itself:
onClipEvent (enterFrame) {
loading = _parent.getBytesLoaded();
total = _parent.getBytesTotal();
percent -= (percent-((loading/total)*100))*.25;
per = int(percent);
percentage = per+"%";
loadBar._width = per;
if (percent>99) {
_parent.gotoAndStop(2);
}
}
Now if I am looking at it right, the issue is with the fact that if a variable is previously undefined, Actionscript 2.0 evaluates it in a numerical context as "NaN" instead of "0", which screws everything up for the 'percent' variable.
Has anyone got any ideas for trying to fix this ? :confused:
Cheers!