ProblemYou want to display seconds or milliseconds in minutes and seconds (mm:ss) format. SolutionUse either the custom ascb.util.DateFormat.formatSeconds( ) or ascb.util.DateFormat.formatMilliseconds( ) methods. DiscussionMany values in ActionScript are given in milliseconds or seconds. For example, sound lengths are given in milliseconds. However, in most cases, you want to format the value as minutes and seconds when displaying it to the user. You can accomplish this with a short amount of code. To further simplify things, that code has already been made into static methods of the DateFormat class. The ascb.utils.DateFormat class has two methods that convert a number to the format mm:ss. The formatSeconds( ) method converts seconds to that format, while the formatMilliseconds( ) method converts milliseconds to that format. See AlsoRecipe 14.4 |