2 Replies Latest reply on Aug 18, 2009 4:36 AM by Gregory Lafrance

    Data binding for date chooser

    Anti-Girl

      Hey Just wondering if its possible to use actionscript variables for a HTTPservice, [not having to use httpservice via actionscript]

       

      eg

       

      <mx:HTTPService id="req"  showBusyCursor="true" method="POST" url="http://localhost/flex1/add.php" useProxy="false">
      <mx:request xmlns="">
      <day>{dates.selectedDate.getDate()}</day>   //instead of this have something like <day>{day.value}</day>  ??????
      <month>{dates.selectedDate.getMonth()}</month>
      <year>{dates.selectedDate.getFullYear()}</year>
      </mx:request>
      </mx:HTTPService>

       

      <mx:Script>
              <![CDATA[
                  [Bindable] private var dateString:String;
                 
                  public var day:int;
                  public var month:int;
                  public var year:int;

       

                
                  public function onClick():void
                  {
                      day = dates.selectedDate.date;
                      month = dates.selectedDate.month;
                      year = dates.selectedDate.getFullYear();
                 }
              ]]>
          </mx:Script>

       

       

       

          <mx:DateChooser id="dates" x="25" y="26" width="221" height="208" allowMultipleSelection="true" showToday="true" change="onClick()"/>

        • 1. Re: Data binding for date chooser
          Madhav Subedi Level 4

          you can do

          <day>{day}</day> // no need to access day.value

           

          but you should declare day Bindable.

          • 2. Re: Data binding for date chooser
            Gregory Lafrance Level 6

            Are you getting an error? Maybe you just need to make the other variables Bindable?

             

            If this post answers your question or helps, please mark it as such.

             

            <?xml version="1.0"?>
            <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
              <mx:Script>
                <![CDATA[
                  [Bindable] public var day:int;
                  [Bindable] public var month:int;
                  [Bindable] public var year:int;
            
                  public function onClick():void{
                    day = dates.selectedDate.date;
                    month = dates.selectedDate.month;
                    year = dates.selectedDate.getFullYear()
                  }
                ]]>
              </mx:Script>
              <mx:DateChooser id="dates" x="25" y="26" width="221" height="208" 
                allowMultipleSelection="true" showToday="true" change="onClick()"/>
              <mx:TextArea id="txt" text="{dates.selectedDate.getDate() + ' ' + dates.selectedDate.getMonth() + ' ' + dates.selectedDate.getFullYear()}"/>  
            </mx:Application>