SPrintf
ormatted strings are a real convenience—one that is sorely missing from the Flash Actionscript library. This adds in the sprintf functionality, which lets you reduce something like this:
Actionscript:
-
var m,d;
-
var myDate = new Date();
-
-
m = myDate.getMonth() + 1;
-
if (m <10)
-
m = '0' + m;
-
-
d = myDate.getDate();
-
if (d <10)
-
d = '0' + d;
-
-
trace(m + '-' + d + '-' + myDate.getFullYear());
-
// traces out: 02-14-2004
into basically a single line of code:
Actionscript:
-
var myDate = new Date();
-
Sprintf.trace('%02d-%02d-%4d',myDate.getMonth() + 1, »
-
myDate.getDate(),myDate.getFullYear()));
-
// traces out: 02-14-2004
http://natecook.com/downloads/sprintf.html
No Comments »
RSS feed for comments on this post.
| TrackBack URI
You can also bookmark
this on del.icio.us or check the cosmos