1 Reply Latest reply on Aug 31, 2009 4:39 AM by ShardulSingh

    Managing the values of the actual day, month and year

    Augusto Esteves Level 1

      Hi,

       

      I'm trying to get into numeric variables the actual day (format: 1 / 10), month (format: 1 / 10), and year (format: 1900). I tried using this example:

       

      <mx:DateFormatter id="DDformatter" formatString="DD"/>

      <mx:DateFormatter id="MMformatter" formatString="MM"/>

      <mx:DateFormatter id="YYYYformatter" formatString="YYYY"/>

       

      Inside the Script:

      private var actualDate:Date = new Date();

       

      [Bindable] private var actualDay:String = DDformatter.format(actualDate);

      [Bindable] private var actualMonth:String = MMformatter.format(actualDate);

      [Bindable] private var actualYear:String = YYYYformatter.format(actualDate);

       

      A part from getting an error when I run my application (am I missing some import?) I would like to have this data in numeric variables:

       

      Error #1009 - Cannot access a property or method of a null object reference.

       

       

        • 1. Re: Managing the values of the actual day, month and year
          ShardulSingh

          Pls find the solution of your problem....let me know if you have any issue.

           

          MainApplication.mxml

           

          <?xml version="1.0" encoding="utf-8"?>

          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"

          layout="absolute" creationComplete="onCreationComplete()">

          <mx:Script>

          <![CDATA[

           

          private var actualDate:Date = new Date();

           

          [Bindable]

          private var actualDay:String;

           

          [Bindable]

          private var actualMonth:String;

           

          [Bindable]

          private var actualYear:String;

           

          private function onCreationComplete():void

          {

          actualDay = DDformatter.format(actualDate);

          actualMonth = MMformatter.format(actualDate);

          actualYear = YYYYformatter.format(actualDate);

          }

           

          ]]>

          </mx:Script>

          <mx:DateFormatter id="DDformatter" formatString="DD"/>

          <mx:DateFormatter id="MMformatter" formatString="MM"/>

          <mx:DateFormatter id="YYYYformatter" formatString="YYYY"/>

          <mx:VBox width="500" height="300">

          <mx:HBox>

          <mx:Label width="150" text="Date"/>

          <mx:Label id="dayLbl" text="{actualDay}"/>

          </mx:HBox>

          <mx:HBox>

          <mx:Label width="150" text="Month"/>

          <mx:Label id="monthLbl" text="{actualMonth}"/>

          </mx:HBox>

          <mx:HBox>

          <mx:Label width="150" text="Year"/>

          <mx:Label id="yearLbl" text="{actualYear}"/>

          </mx:HBox>

           

           

           

          </mx:VBox>

          </mx:Application>

           

           

           

          with Regards,

          Shardul Singh Bartwal