-
Preloader broken. :(
OK In a previous game on the same AS (2), I made a preloader, the code worked fine, all of the code was isolated on one frame so on another game I copied the frame and pasted into my other game. but the only difference is that one of my games is using flash player 8 (working preloader) and the other is using flash player 6 (not working.) Im using the same code.
here is the frame code (all of it on frame):
Code:
var loadingCall:Number = setInterval(preloadSite, 50);
function preloadSite():Void {
var siteLoaded:Number = _root.getBytesLoaded();
var siteTotal:Number = _root.getBytesTotal();
_root.percentage = Math.round(siteLoaded/siteTotal*100);
percentDisplay = _root.percentage+"%";
bytesDisplay.text = "loaded "+siteLoaded+" of "+siteTotal+" bytes";
if (siteLoaded>=siteTotal) {
clearInterval(loadingCall);
}
trace (_root.percentage + " percent")
if (_root.percentage >= 100) {
trace("percentage = 100")
}
}
I get the output error of this when played :
Code:
**Error** Scene=Scene 1, layer=preloader, frame=1:Line 4: '{' expected
function preloadSite():Void {
**Error** Scene=Scene 1, layer=preloader, frame=1:Line 17: Unexpected '}' encountered
}
Total ActionScript Errors: 2 Reported Errors: 2
-
I just relised the preloader code is AS2 but my game is AS1 will someone tell me how to fix it please, it's probaly really simple.
-
Maybe try something like this...
Code:
var loadingCall = setInterval(preloadSite, 50);
function preloadSite() {
var siteLoaded = _root.getBytesLoaded();
var siteTotal = _root.getBytesTotal();
_root.percentage = Math.round(siteLoaded/siteTotal*100);
percentDisplay = _root.percentage+"%";
bytesDisplay.text = "loaded "+siteLoaded+" of "+siteTotal+" bytes";
if (siteLoaded>=siteTotal) {
clearInterval(loadingCall);
}
trace(_root.percentage+" percent");
if (_root.percentage>=100) {
trace("percentage = 100");
}
}