A Flash Developer Resource Site

Page 3 of 3 FirstFirst 123
Results 41 to 54 of 54

Thread: [Preview] IK Snake

  1. #41
    Member
    Join Date
    Nov 2006
    Posts
    93
    I have a question. How did you make your score like that so it reads 00000000 and counts up? I can only get my score to work if it starts as 0

  2. #42
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,379
    Search: Key Word(s): score
    Showing results 1 to 25 of 382
    Search took 6.47 seconds.
    Code:
    onClipEvent (load) {
    	var one = 0;
    	var ten = 0;
    	var hun = 0;
    	var tho = 0;
    	var tentho = 0;
    	var huntho = 0;
    }
    onClipEvent (enterFrame) {
    	if (_root.scoreHolder>0) {
    		_root.scoreHolder--;
    		if (one+1 != 10) {
    			one++
    		} else {
    			one = 0
    			if (ten+1 != 10) {
    				ten++
    			} else {
    				ten = 0
    				if (hun+1 != 10) {
    					hun++
    				} else {
    					hun = 0
    					if (tentho+1 != 10) {
    						tentho++
    					}else {
    						tentho = 0
    						huntho++
    					}
    				}
    			}
    		}
    	}
    	_root.score = huntho+""+tentho+""+tho+""+hun+""+ten+""+one;
    }
    Leave a blank MC offstage with this code in it. Then whenever a player scores points, add those points to _root.scoreHolder instead of directly to the score.
    Last edited by ImprisonedPride; 11-16-2006 at 01:11 PM.
    The 'Boose':
    ASUS Sabertooth P67 TUF
    Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
    8GB G.Skill Ripjaws 1600 DDR3
    ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
    New addition: OCZ Vertex 240GB SATA III SSD
    WEI Score: 7.6

  3. #43
    Member
    Join Date
    Nov 2006
    Posts
    93
    I have searched that before and never found this code about it

    Sorry and thanks

    Is it easy to change the speed in which it goes up, perhaps flicks through tens instead of ones? I've tried but so far I only managed to make it go up to 1000 by mistake

    [EDIT]: Hmm..when the score gets to 1000, the rolling bar jumps to 10,000. Gonna try and figure out whats wrong :S
    Last edited by xtrava; 11-16-2006 at 03:18 PM.

  4. #44
    Member
    Join Date
    Nov 2006
    Posts
    93
    Hmm cant work it out, seems to be an inherent problem with it

    Am using this instead:
    Code:
    onClipEvent (enterFrame) {
     if (_root.score<_root.scoreC) {
     _root.score += 10;
     }
    Just a shame it means by display doesnt appear as 000000, but at least it goes up properly, and quickly

  5. #45
    Banned XareoX's Avatar
    Join Date
    Aug 2006
    Posts
    462
    http://img206.imageshack.us/my.php?image=testup8.swf

    is this what you mean i made it so it doesnt have much code as well its realy 10000 but i masked out the 1 =)

    hope its what you need

    heres the source file.
    Attached Files Attached Files

  6. #46
    383,890,620 polygons nGFX's Avatar
    Join Date
    Oct 2002
    Location
    Germany / Ruhrgebiet
    Posts
    902
    ... well masking out is ... an interresting approach ...

    or you coud use this:
    Code:
    /**
    * returns a string formated to the total length of Size
    * padded with leading zeros
    * 
    * @param	value	an object (text or number) to be padded
    * @param	size 	[optinal] the length of the resulting string
    * @return			the padded string
    */
    function format (value:Object, size:Number):String {
    	
    	var stringValue:String = String(value);
    	var strLength = 2;
    	
    	if (size != null) strLength = size;
    	while (stringValue.length < strLength) {
    	         stringValue = "0" + stringValue;
    	}
    	
    	return stringValue;
    }
    
    // usage:
    
    trace( format(1) );
    // outputs: 01 
    
    trace( format(123, 5) );
    // outputs: 00123
    if you're on AS2 you colud just use the attached StrUtil class, which contains some more string related thingies ... (rename to .as, though) - wow my first open source.

    nGFX
    Attached Files Attached Files

  7. #47
    Member
    Join Date
    Nov 2006
    Posts
    93
    Quote Originally Posted by XareoX
    http://img206.imageshack.us/my.php?image=testup8.swf

    is this what you mean i made it so it doesnt have much code as well its realy 10000 but i masked out the 1 =)

    hope its what you need

    heres the source file.

    My MX cant load that

    Sounds like a good idea though I'll come back to it

  8. #48
    Hype over content... Squize's Avatar
    Join Date
    Apr 2001
    Location
    Lost forever in a happy crowd...
    Posts
    5,928
    Wow, this thread's been hijacked.

    "Sounds like a good idea"

    Erm, no, it's a really bad way to do it. Use nGFX's code, it's a million times better.

    Squize.

  9. #49
    Senior Member mbenney's Avatar
    Join Date
    Mar 2001
    Posts
    2,744
    ah but its faster if you're displaying in a dynamic text box anyway.

  10. #50
    Banned XareoX's Avatar
    Join Date
    Aug 2006
    Posts
    462
    Squize
    masking still does the same thing and way easyer

  11. #51
    Senior Member ihoss.com's Avatar
    Join Date
    Oct 2004
    Location
    Norway
    Posts
    581
    Masking is slower and a clumsy way to do something simple. If you don't want to show the 1 then just use score.toString().substring(1);

    Domyboy, spamming is not accepted

  12. #52
    Banned XareoX's Avatar
    Join Date
    Aug 2006
    Posts
    462
    self deleted =)
    Last edited by XareoX; 11-19-2006 at 12:44 AM.

  13. #53
    Trainee coder Viza's Avatar
    Join Date
    Sep 2006
    Location
    Melbourne, Down under
    Posts
    513
    Calm down Xareox.
    You obviously didn't read what was above ihoss's post because some guy named 'domyboy' spammed in this thread...He wasnt attacking you.
    Last edited by tonypa; 11-19-2006 at 05:03 AM.

  14. #54
    Banned XareoX's Avatar
    Join Date
    Aug 2006
    Posts
    462
    sry =}

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