<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: AS2 / AS3 Game Score Formatter</title>
	<atom:link href="http://snipplr.com/blog/2008/09/11/as2-as3-game-score-formatter/feed/" rel="self" type="application/rss+xml" />
	<link>http://snipplr.com/blog/2008/09/11/as2-as3-game-score-formatter/</link>
	<description>s nipple r &#60;em&#62;dot com!&#60;/em&#62;</description>
	<lastBuildDate>Fri, 16 Mar 2012 15:45:49 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jim</title>
		<link>http://snipplr.com/blog/2008/09/11/as2-as3-game-score-formatter/comment-page-1/#comment-17344</link>
		<dc:creator>Jim</dc:creator>
		<pubDate>Wed, 22 Apr 2009 11:01:33 +0000</pubDate>
		<guid isPermaLink="false">http://snipplr.com/blog/?p=97#comment-17344</guid>
		<description>Oops, left the abs() in, but the score = -score takes care of that.</description>
		<content:encoded><![CDATA[<p>Oops, left the abs() in, but the score = -score takes care of that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jim</title>
		<link>http://snipplr.com/blog/2008/09/11/as2-as3-game-score-formatter/comment-page-1/#comment-17343</link>
		<dc:creator>Jim</dc:creator>
		<pubDate>Wed, 22 Apr 2009 10:59:38 +0000</pubDate>
		<guid isPermaLink="false">http://snipplr.com/blog/?p=97#comment-17343</guid>
		<description>Neither shorter answer takes the negative value into account...  I don&#039;t know Flash/ActionScript, but this pseudo code suggests the original could be much cleaner:

addZeros( score, digits ) {
  var prefix = &quot;&quot;;
  if( score &lt; 0 ) {
    prefix = &quot;-&quot;;
    score = -score;
  }
  for( i = abs(score).toString().length; i &lt; digits; i++ ) {
    prefix += &quot;0&quot;;
  }
  return prefix + score;
}</description>
		<content:encoded><![CDATA[<p>Neither shorter answer takes the negative value into account&#8230;  I don&#8217;t know Flash/ActionScript, but this pseudo code suggests the original could be much cleaner:</p>
<p>addZeros( score, digits ) {<br />
  var prefix = &#8220;&#8221;;<br />
  if( score &lt; 0 ) {<br />
    prefix = &#8220;-&#8221;;<br />
    score = -score;<br />
  }<br />
  for( i = abs(score).toString().length; i &lt; digits; i++ ) {<br />
    prefix += &#8220;0&#8243;;<br />
  }<br />
  return prefix + score;<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jason</title>
		<link>http://snipplr.com/blog/2008/09/11/as2-as3-game-score-formatter/comment-page-1/#comment-16586</link>
		<dc:creator>Jason</dc:creator>
		<pubDate>Wed, 15 Oct 2008 18:26:48 +0000</pubDate>
		<guid isPermaLink="false">http://snipplr.com/blog/?p=97#comment-16586</guid>
		<description>Heres an even shorter (and recursive) soloution (in javascript):


    function addZeros(score,digits) {
	    if(score.length &gt;= digits) { return score; }	
	    return addZeros(&quot;0&quot;+score,digits);
    }


Call with `addZeros((549).toString(),7);`

Will return `&quot;0000549&quot;`</description>
		<content:encoded><![CDATA[<p>Heres an even shorter (and recursive) soloution (in javascript):</p>
<p>    function addZeros(score,digits) {<br />
	    if(score.length &gt;= digits) { return score; }<br />
	    return addZeros(&#8220;0&#8243;+score,digits);<br />
    }</p>
<p>Call with `addZeros((549).toString(),7);`</p>
<p>Will return `&#8221;0000549&#8243;`</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pear</title>
		<link>http://snipplr.com/blog/2008/09/11/as2-as3-game-score-formatter/comment-page-1/#comment-16537</link>
		<dc:creator>pear</dc:creator>
		<pubDate>Sun, 05 Oct 2008 02:00:13 +0000</pubDate>
		<guid isPermaLink="false">http://snipplr.com/blog/?p=97#comment-16537</guid>
		<description>I took a look at this code and it looked pretty complicated to me. I mean, it looks nice, but I came up with a shorter way. 
function format(num:Number, digits:Number) {
	var answer;
	for (var i = 0; i&lt;(digits-num.toString().length); i++) {
		if (i == 0) {
			answer = &quot;0&quot;;
		} else {
			answer += &quot;0&quot;;
		}
	}
	answer += num;
	return answer;
}
Just felt like sharing...</description>
		<content:encoded><![CDATA[<p>I took a look at this code and it looked pretty complicated to me. I mean, it looks nice, but I came up with a shorter way.<br />
function format(num:Number, digits:Number) {<br />
	var answer;<br />
	for (var i = 0; i&lt;(digits-num.toString().length); i++) {<br />
		if (i == 0) {<br />
			answer = &#8220;0&#8243;;<br />
		} else {<br />
			answer += &#8220;0&#8243;;<br />
		}<br />
	}<br />
	answer += num;<br />
	return answer;<br />
}<br />
Just felt like sharing&#8230;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
