I have found that code containing nested switch/case statements fail to work correctly even though they compile without errors.
I'm including two different versions of the same code, one using switch/case statements, the other using if/else statements. The switch/case version won't allow me to set breakpoints or examine variables in the code following the switch/case statements, although I can single-step through each line of the code during debugging. The if/else version works as expected. ***** SWITCH/CASE VERSION ***** private function clickHandler(clickEvent:ItemClickEvent):void { switch (clickEvent.index) { case VIEW_PREVIOUS: // Previous { switch (ecModel.viewingMode) { case (EventCalendarModel.VIEWING_MODE_DAYS): ecModel.addDaysToSelectedTime(-1); break; case (EventCalendarModel.VIEWING_MODE_WEEKS): ecModel.addWeeksToSelectedTime(-1); break; case (EventCalendarModel.VIEWING_MODE_MONTHS): ecModel.addMonthsToSelectedTime(-1); break; } } break; case VIEW_DATESELECTOR: // Select date break; case VIEW_NEXT: // Next switch (ecModel.viewingMode) { case (EventCalendarModel.VIEWING_MODE_DAYS): ecModel.addDaysToSelectedTime(1); break; case (EventCalendarModel.VIEWING_MODE_WEEKS): ecModel.addWeeksToSelectedTime(1); break; case (EventCalendarModel.VIEWING_MODE_MONTHS): ecModel.addMonthsToSelectedTime(1); break; } break; } // Explicitly generate a PropertyChangeEvent so binding will work as expected if (ecPreviousDate.getTime() != ecModel.selectedTime.getTime()) { var pcEvent:PropertyChangeEvent = new PropertyChangeEvent(PropertyChangeEvent.PROPERTY_CHANGE); pcEvent.kind = "update"; pcEvent.property = "selectedTime"; pcEvent.oldValue = ecPreviousDate.getTime(); pcEvent.newValue = ecModel.selectedTime.getTime(); pcEvent.source = ecModel; dispatchEvent(pcEvent); } } } ***** IF/ELSE VERSION ***** private function clickHandler(clickEvent:ItemClickEvent):void { var ecPreviousDate:Date = new Date(ecModel.selectedTime); if (clickEvent.index == VIEW_PREVIOUS) // Previous button clicked { if (ecModel.viewingMode == EventCalendarModel.VIEWING_MODE_DAYS) { // Previous Day ecModel.addDaysToSelectedTime(-1); } else if (ecModel.viewingMode == EventCalendarModel.VIEWING_MODE_WEEKS) { // Previous Week ecModel.addWeeksToSelectedTime(-1); } else if (ecModel.viewingMode == EventCalendarModel.VIEWING_MODE_MONTHS) { // Previous Month ecModel.addMonthsToSelectedTime(-1); } } else if (clickEvent.index == VIEW_NEXT) // Next button clicked { if (ecModel.viewingMode == EventCalendarModel.VIEWING_MODE_DAYS) { ecModel.addDaysToSelectedTime(1); } else if (ecModel.viewingMode == EventCalendarModel.VIEWING_MODE_WEEKS) { ecModel.addWeeksToSelectedTime(1); } else if (ecModel.viewingMode == EventCalendarModel.VIEWING_MODE_MONTHS) { ecModel.addMonthsToSelectedTime(1); } } // Explicitly generate a PropertyChangeEvent so binding will work as expected if (ecPreviousDate.getTime() != ecModel.selectedTime.getTime()) { var pcEvent:PropertyChangeEvent = new PropertyChangeEvent(PropertyChangeEvent.PROPERTY_CHANGE); pcEvent.kind = "update"; pcEvent.property = "selectedTime"; pcEvent.oldValue = ecPreviousDate.getTime(); pcEvent.newValue = ecModel.selectedTime.getTime(); pcEvent.source = ecModel; dispatchEvent(pcEvent); } } -- Flexcoders Mailing List FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> Your email settings: Individual Email | Traditional <*> To change settings online go to: http://groups.yahoo.com/group/flexcoders/join (Yahoo! ID required) <*> To change settings via email: mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/