= secondsSpinner.dataProvider.length - 1){
// seconds loops back to zero
nextSecondsIndex = 0;
// reached zero seconds so decrement the minute spinner
var currentMinutesIndex:int = minutesSpinner.selectedIndex;
var nextMinutesIndex:int = currentMinutesIndex + 1;
if (currentMinutesIndex >= minutesSpinner.dataProvider.length - 1){
// minutes loops back to zero
nextMinutesIndex = 0;
// reached zero minutes so decrement the hour spinner
var currentHoursIndex:int = hoursSpinner.selectedIndex;
var nextHoursIndex:int = currentHoursIndex + 1;
if (currentHoursIndex >= hoursSpinner.dataProvider.length - 1){
nextHoursIndex = 0;
// the timer has reached 0,0,0 so ring the alarm
handleTimerCompleted();
// return so the spinners stay at the last index
return;
} else {
hoursSpinner.animateToSelectedIndex(nextHoursIndex);
}
minutesSpinner.selectedIndex = 0;
} else {
minutesSpinner.animateToSelectedIndex(nextMinutesIndex);
}
secondsSpinner.selectedIndex = 0;
} else {
secondsSpinner.animateToSelectedIndex(nextSecondsIndex);
}
}
private function handleTimerCompleted():void {
stopTimer();
alarmNotification.open(this, true);
// put the start button back
startStopButton.label = "Start";
startStopButton.setStyle("chromeColor", "green");
trace('Timer Complete');
trace('Ring!');
}
private function stopTimer():void {
timer.removeEventListener(TimerEvent.TIMER, handleTimerUpdate);
timer.stop();
timer = null;
}
private function resetSpinner(event:MouseEvent):void
{
hoursSpinner.selectedIndex = hoursSpinner.dataProvider.length - 1;
minutesSpinner.selectedIndex = 0;
secondsSpinner.selectedIndex = secondsSpinner.dataProvider.length - 1;
}
private function setInitialHourValue(event:FlexEvent):void
{
hoursSpinner.selectedIndex = hoursSpinner.dataProvider.length - 1;
}
private function setInitialMinuteValue(event:FlexEvent):void
{
minutesSpinner.selectedIndex = 0;
}
private function setInitialSecondsValue(event:FlexEvent):void
{
secondsSpinner.selectedIndex = secondsSpinner.dataProvider.length - 1;
}
private function toggleStartTop(event:MouseEvent):void
{
if (timer && timer.running) {
// stop the timer
stopTimer();
startStopButton.label = "Start";
startStopButton.setStyle("chromeColor", "green");
} else {
// start the timer
startTimerCountdown(event);
startStopButton.label = "Stop";
startStopButton.setStyle("chromeColor", "red");
}
}
]]>