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()">
            private function init():void{
            var now:Date = new Date();
            var dayOfWeek:int = now.day;
            case 0:
            dow.text = "Sunday";
            case 1:
            dow.text = "Monday";
            case 2:
            dow.text = "Tuesday";
            case 3:
            dow.text = "Wednesday";
            case 4:
            dow.text = "Thursday";
            case 5:
            dow.text = "Friday";
            case 6:
            dow.text = "Saturday";
            <mx:Label text="Today is: "/>
            <mx:Label id="dow"/>