A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Preloader broken. :(

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    7

    Unhappy 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

  2. #2
    Junior Member
    Join Date
    Jan 2010
    Posts
    7
    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.

  3. #3
    :
    Join Date
    Dec 2002
    Posts
    3,518
    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");
    	}
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center