
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
410
|
Chapter 18: The Model-View-Controller Design Pattern
} else {
clock_txt.textColor = 0x666666;
}
}
/**
* Returns a formatted 24-hour time string.
*
* @param h The hour, from 0 to 23.
* @param m The minute, from 0 to 59.
* @param s The second, from 0 to 59.
*/
private function formatTime24 (h:Number, m:Number, s:Number):String {
var timeString:String = "";
// Format hours...
if (h < 10) {
timeString += "0";
}
timeString += h + separator;
// Format minutes...
if (m < 10) {
timeString += "0";
}
timeString += m + separator;
// Format seconds...
if (s < 10) {
timeString += "0";
}
timeString += String(s);
return timeString;
}
/**
* Returns a formatted 12-hour time string (not including AM or PM).
*
* @param h The hour, from 0 to 23.
* @param m The minute, from 0 to 59.
* @param s The second, from 0 to 59.
*/
private function formatTime12 (h:Number, m:Number, s:Number):String {
var timeString:String = "";
// Format hours...
if (h == 0) {
timeString += "12" + separator;
} else if (h > 12) {
timeString += (h - 12) + separator;
} else {
Example 18-8. The ClockDigitalView class (continued)