2 Replies Latest reply on Jun 25, 2008 8:47 AM by Gregory Lafrance

    Detect day of the week?

    Handycam Level 1
      I'm trying to build an app with a tabbed interface, where there is one tab for each day of the week. Depending on the day, the app will bring frontmost the appropriate tab (although the user can still browse the other days).

      How can I detect what day of the week it is at app launch (page load)? Not date, day of the week. Thanks.
        • 1. Re: Detect day of the week?
          Handycam Level 1
          Never mind, forgot I can get that using the Date object:

          private var days:Array = ['Sunday', 'Monday', 'Tuesday','Wednesday','Thursday','Friday','Saturday'];

          private function whatDayIsIt():void {
          var timenow:Date = new Date();
          weekday.text = days[timenow.getDay()];
          }
          • 2. Re: Detect day of the week?
            Gregory Lafrance Level 6
            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" creationComplete="init()">
            <mx:Script>
            <![CDATA[
            private function init():void{
            var now:Date = new Date();
            var dayOfWeek:int = now.day;
            switch(dayOfWeek){
            case 0:
            dow.text = "Sunday";
            break;
            case 1:
            dow.text = "Monday";
            break;
            case 2:
            dow.text = "Tuesday";
            break;
            case 3:
            dow.text = "Wednesday";
            break;
            case 4:
            dow.text = "Thursday";
            break;
            case 5:
            dow.text = "Friday";
            break;
            case 6:
            dow.text = "Saturday";
            break;
            }
            }
            ]]>
            </mx:Script>
            <mx:Label text="Today is: "/>
            <mx:Label id="dow"/>
            </mx:Application>