A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Action Script syntax.....

  1. #1
    Junior Member
    Join Date
    Mar 2002
    Posts
    23

    Post

    I am trying to make my first preloader and seem to be having some kind of problem with the code if anyone could help me

    this is the script

    code is

    loadPercent = (Math.floor (_root.getBytesLoaded() / _root.getBytesTotal() * 100) + "%");
    loadBytes = (Math.round((_root.getBytesLoaded() / 1024) * 1000) / 1000) + " Kb of " + Math.round((_root.getBytesTotal() / 1024) * 1000) / 1000 + " Kb total Loaded ");
    if (_root.getBytesLoaded() == _root.getBytesTotal()){ loadPercent = "100%";
    loadBytes = (Math.round((_root.getBytesLoaded() / 1024) * 1000) / 1000) + " Kb of " + Math.round((_root.getBytesTotal() / 1024) * 1000) / 1000 + " Kb total Loaded ");
    }else{
    //what frame is labled "button"? is it the 2nd Frame?
    gotoAndPlay("Button");
    }

    the error is .................................................. .......................

    Error
    Scene=Scene 1, Layer=actions, Frame=2: Line 2: ';' expected
    loadBytes = (Math.round((_root.getBytesLoaded() / 1024) * 1000) / 1000) + " Kb of " + Math.round((_root.getBytesTotal() / 1024) * 1000) / 1000 + " Kb total Loaded ");


    Please help me out I can't find where the darn ";" is supposed to be I know that ; is supposed to end a statement but that's one fluid statement in my actionscript.

    well thnxs for any help you can offer


  2. #2
    HELP>>>ACTIONSCRIPT DICTIONARY
    Join Date
    Feb 2000
    Location
    In the Present Moment
    Posts
    1,041
    you had some parentheses that were throwing Flash off:

    Code:
    
    loadPercent = Math.floor (_root.getBytesLoaded() / _root.getBytesTotal() * 100) + "%"; 
    	loadBytes = Math.round((_root.getBytesLoaded() / 1024) * 1000) / 1000 + " Kb of " + Math.round((_root.getBytesTotal() / 1024) * 1000) / 1000 + " Kb total Loaded "; 
    	if (_root.getBytesLoaded() == _root.getBytesTotal()){ 
    		     loadPercent = "100%"; 
    		     loadBytes = Math.round(((_root.getBytesLoaded() / 1024) * 1000) / 1000) + " Kb of " + Math.round(((_root.getBytesTotal() / 1024) * 1000) / 1000) + " Kb total Loaded " ; 
    	 }else{ 
    		     //what frame is labled "button"? is it the 2nd Frame? 
    		     gotoAndPlay("Button"); 
    	} 
    

    original code : missing an opening parentheses after the first Math.round

    loadBytes = (Math.round((_root.getBytesLoaded() / 1024) * 1000) / 1000) + " Kb of " + Math.round((_root.getBytesTotal() / 1024) * 1000) / 1000 + " Kb total Loaded ");

    First ( gets moved to after the Math.round and the last ) gets removed period.

    loadBytes = Math.round(((_root.getBytesLoaded() / 1024) * 1000) / 1000) + " Kb of " + Math.round((_root.getBytesTotal() / 1024) * 1000) / 1000 + " Kb total Loaded ";

    I suppose you could do this too:

    loadBytes = (Math.round(((_root.getBytesLoaded() / 1024) * 1000) / 1000) + " Kb of " + Math.round((_root.getBytesTotal() / 1024) * 1000) / 1000 + " Kb total Loaded ");

    It isn't necessary to surround the whole thing in ( ) but you can if you want to.

    Anyway, make sure your parentheticals open and close properly.

    Good Luck!

  3. #3
    Junior Member
    Join Date
    Mar 2002
    Posts
    23
    thanks a ton got my preloader up and running due to your help

    thnxs again

  4. #4
    HELP>>>ACTIONSCRIPT DICTIONARY
    Join Date
    Feb 2000
    Location
    In the Present Moment
    Posts
    1,041
    Good Job!

    You're welcome, I'm glad to help.

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