I worked on a couple projects a while back that required a stopwatch (or timer) to keep track of time in a game, so I made this StopWatch class. Found it very helpful so I wanna share it. Besides the basic functions of starting, stopping, and resetting, you can also pass in a TextFormat object to change the formatting of the text, get the time in milliseconds (it's what I used to store in the database), and parse the milliseconds back into something more readable..
Here's how to use it:
import ca.ryac.StopWatch; // creates a StopWatch obj and sets the formatting to the txtFormat obj.. // last parameter will set embeddedFonts to either true or false (default is false).. var sw:StopWatch = new StopWatch (txtFormat, true); // pretty self-explanatory.. sw.start (); sw.stop (); sw.reset (); // set or change the formatting and sets embeddedFonts to true.. sw.setTextFormat (txtFormat2, true); // output the time in milliseconds trace (sw.time); StopWatch.parseTime (87292); // returns 01:27:29