8 Replies Latest reply on Sep 25, 2009 12:15 AM by Yogi_ACE

    Plz help

    xcavan

      I am new to flex and have created a custom component. It is basically a popup through which you can select a date.

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

       

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

      <mx:TitleWindow

       

       

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

      "

      layout="

       

      absolute

      "

      title="

       

      Choose date

      "

      showCloseButton="

       

      false

      "

      width="

       

      132

      "

      height="

       

      98" defaultButton="{winok}"

      >

       

       

       

      <mx:Script>

      <![CDATA[

       

       

       

      public var

      rdate:Date;

       

       

      import

      mx.events.CloseEvent;

       

       

      import

      mx.managers.PopUpManager;

       

       

       

      private function titleWindow_close():void

      {

      PopUpManager.removePopUp(

       

      this

      );

      }

       

       

      public function

      retdate():Date

      {

       

       

      var

      date:Date = rdate;

       

       

      return

      date;

      }

       

       

      private function init():

      void

      {

      dtchsr.selectableRange={rangeStart:

       

      new Date(2007,0,0),rangeEnd: new

      Date()};

      }

      ]]>

       

       

      </mx:Script>

       

       

       

      <mx:DateField id="dtchsr" change="{rdate = dtchsr.selectedDate}" formatString="DD/MM/YYYY" creationComplete="init()" x="0" y="0"

      />

       

       

      <mx:ControlBar>

       

       

      <mx:Button label="OK" click="titleWindow_close()" id="winok"

      />

       

       

      <mx:Button label="Cancel" click="titleWindow_close()" id="wincancle"

      />

       

       

      </mx:ControlBar>

       

      </mx:TitleWindow>

       

       

       

      i tried using the popupmanager to deploy this window. but i am unable to retrive the date as the code keep on executing and retrives a null date.

       

      mywindow = PopUpManager.createPopUp(this, dtch, true) as

      dtch;

      dat = mywindow.retdate();

      teststring.text = dat.date.toString() +

       

      '/' + dat.month.toString() + '/'

      + dat.fullYear.toString();

       

       

       

        • 1. Re: Plz help
          Yogi_ACE

          If you have lack of time then simple way is to store value at your .mxml file

           

          <!-- Your .mxml file -->

          <mx:Script>

          <![CDATA[

           

                         public var dateRange:Date;

           

          ]]>

          </mx:Script>

           

          - - - - - - - - - - - - - - -

           

          <!-- Component MXML -->

          on change you can set value as,

          Application.application.dateRange = dtchsr.selectedDate;

           

          --------------------

           

          And dateRange will be available through out your application. *(Remember it is work around and not the preferable solution)

           

          If this answer helps you then please mark it as answered.

           

          Best Regards,

          Yogesh

          1 person found this helpful
          • 2. Re: Plz help
            xcavan Level 1

            Dear Yogesh,

             

            Thanks for your reply...But now I am getting the following error:


            1119: Access of possibly undefined property dat through a reference with static type Class.   Diary/src/com dtch.mxml line 32 1253788129525 1241

             

            I am Building an AIR application.

             

            Regards,

            Saurav

            • 3. Re: Plz help
              Yogi_ACE Level 2

              what is there on:

              Diary/src/com dtch.mxml line 32

               

              Can you share 4-5 lines around above and below line 32 from dtch.mxml?

              1 person found this helpful
              • 4. Re: Plz help
                xcavan Level 1

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

                 

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

                <mx:TitleWindow

                 

                 

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

                "

                layout="

                 

                absolute

                "

                title="

                 

                Choose date

                "

                showCloseButton="

                 

                false

                "

                width="

                 

                132

                "

                height="

                 

                98" defaultButton="{winok}"

                >

                 

                 

                 

                <mx:Script>

                <![CDATA[

                 

                 

                 

                public var

                rdate:Date;

                 

                 

                import

                mx.events.CloseEvent;

                 

                 

                import

                mx.managers.PopUpManager;

                 

                 

                 

                private function titleWindow_close():void

                {

                PopUpManager.removePopUp(

                 

                this

                );

                }

                 

                 

                public function

                retdate():Date

                {

                 

                 

                var

                date:Date = rdate;

                 

                 

                return

                date;

                }

                 

                 

                private function init():

                void

                {

                dtchsr.selectableRange={rangeStart:

                 

                new Date(2007,0,0),rangeEnd: new

                Date()};

                 

                }

                ]]>

                 

                 

                </mx:Script>

                 

                 

                 

                <mx:DateField id="dtchsr" change="{Diary.dat = dtchsr.selectedDate; }" formatString="DD/MM/YYYY" creationComplete="init()" x="0" y="0"

                />

                 

                 

                <mx:ControlBar>

                 

                 

                <mx:Button label="OK" click="Diary.fdiary(rdate); titleWindow_close()" id="winok"

                />

                 

                 

                <mx:Button label="Cancel" click="titleWindow_close()" id="wincancle"

                />

                 

                 

                </mx:ControlBar>

                 

                </mx:TitleWindow>

                 

                 

                 

                 

                 

                 

                 

                Where Diary is my main mxml file.

                dat is the public variable

                and fdiary()  is a public function which take a date parameter

                • 5. Re: Plz help
                  Yogi_ACE Level 2

                  I am unable to find code at line 32 from dtch; text editor has added unwanted spaces and special characters to the code you have shared.

                   

                  Instead of Diary.dat,

                  have you tried Application.application.dat?

                  • 6. Re: Plz help
                    xcavan Level 1

                    If i Replace Diary.dat with Application.application.dat i get the error:

                     

                    1120: Access of undefined property Application. Diary/src/com dtch.mxml line 32 1253853982118 1300

                     

                    line 32:

                     

                    <mx:DateField id="dtchsr" change="{Application.application.dat = dtchsr.selectedDate; }" formatString="DD/MM/YYYY" creationComplete="init()" x="0" y="0"/>

                     

                     

                     

                    If I use Diary.dat and change the var to static i dont get the error.

                    but agiain i have to access the function fdiary also, which cannot be made static.

                    • 7. Re: Plz help
                      xcavan Level 1

                      Thankyou very much..

                      I wasnt importin the mx.core.Application.....thus the error.

                      It is working finre now.

                      • 8. Re: Plz help
                        Yogi_ACE Level 2

                        Perfect!