Sprintf class for AS2 now available!

Posted on Friday 25 February 2005

The wonderful sprintf function, which first appeared in C, often-used in PHP, allows you to format numbers, strings and dates very easily. Nate Cook implemented a version in Actionscript 1.0 a while ago, and I noticed it didn't work in AS2, so I created a wrapper class that Nate very quickly posted on his site. Example usage:


import com.natecook.Sprintf;

var myDate = new Date();
Sprintf.trace('%02d-%02d-%4d',
    myDate.getMonth() + 1
    myDate.getDate(),
    myDate.getFullYear()));
// traces out: 02-14-2004

Sprintf.trace('%.4f', Math,PI);
// traces out: 3.1416
 

You get two static methods, Sprintf.format and Sprintf.trace which are equivalent to the original sprintf(...) and trace(sprintf(...)), respectively. As for flags, look at the function reference on PHP.net.

Get the class here.


WordPress database error: [Can't open file: 'wp_comments.MYD'. (errno: 145)]
SELECT * FROM wp_comments WHERE comment_post_ID = '44' AND comment_approved = '1' ORDER BY comment_date

No comments have been added to this post yet.

Leave a comment




Your e-mail address is never displayed. If you run into issues with SpamKarma blocking you, email me at $patrick->5etdemi(com)


RSS feed for comments on this post | TrackBack URI