Here is a real quick proto I wrote for you where I stuff your
textInputs everything into an object. Click the Set Text button to c
the data binded to the texfield. If you have any questions shoot a reply.
Thanks,
-Augie Marcello III

<!***************** RecordData.as  *********************>
import mx.controls.TextInput

class com.viva.model.RecordData
 {
          public var recordID:Number;
          public var firstName:String ;
          public var middleName:String;
          public var lastName:String;
          public var address:String;
          public var city:String;
          public var state:String;
          public var zip:String;
          public var heightFt:Number;
          public var heightIn:Number;
          public var weight:Number;
          public var hairColor:String;
          public var eyeColor:String;
          public var dob:Date;
          
          public var obj:Object = {};
          
          public function RecordData() 
          {
                  //Constructor
          }
          
          
/**
  * @function addTextFieldToObj()
  * @usage  Textfields are passed into here. We stuff them into an
object and name them.
  * @param textFieldName:String
  * @param textField:TextInput
  * @return Nothing
  */
          public function addTextFieldToObj(textFieldName:String,
textField:TextInput)
          {
                   obj[textFieldName] = textField;   
          }
          
          
          
 /**
   * @function setText()
   * @usage Binds Data to TextInput fields which we access each
individual through are obj
   * @param Nothing
   * @return Nothing
   */
          public function setText():Void
          {
                        obj.firstName.text = "Douglas"
                        obj.middleName.text = "M"
                        obj.lastName.text = "Arthur"
          }
        

 }


<!**************** Main.as ****************************>

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml"; 
initialize="doInit();">

        <mx:VBox label="Name / Address" width="100%" height="100%">
         
         <mx:Script>
          <![CDATA[
           import mx.controls.Alert;
           import com.viva.model.RecordData;
           
           public var record:RecordData
           
           
           public function doInit():Void
           {
                        record = new RecordData();
           
                        record.addTextFieldToObj("firstName", firstName);
                        record.addTextFieldToObj("middleName",middleName);
                        record.addTextFieldToObj("lastName",lastName);
           }
           
                  
                  
          ]]>
         </mx:Script>
         
         <mx:HBox>
          <mx:Form>
           <mx:FormHeading label="Defendant Name" />
           <mx:FormItem label="First Name">
                <mx:TextInput id="firstName" />
           </mx:FormItem>
           <mx:FormItem label="Middle Name">
                <mx:TextInput id="middleName"/>
           </mx:FormItem>
           <mx:FormItem label="Last Name">
                <mx:TextInput id="lastName" />
           </mx:FormItem>
          </mx:Form>
         
          <mx:Form>
           <mx:FormHeading label="Address" />
           <mx:FormItem label="Number/Street">
                <mx:TextInput />
           </mx:FormItem>
           <mx:FormItem label="City">
                <mx:TextInput />
           </mx:FormItem>
           <mx:FormItem label="State">
                <mx:TextInput />
           </mx:FormItem>
           <mx:FormItem label="Zip Code">
                <mx:TextInput maxChars="9" width="100" restrict="0-9" />
           </mx:FormItem>
          </mx:Form>
          <mx:Button label="Set Text" click="record.setText()" />
         </mx:HBox>
        </mx:VBox>

</mx:Application>












--- In [email protected], "Doug Arthur" <[EMAIL PROTECTED]> wrote:
>
> I have a class that I want to be bindable with text fields... When
the text
> field gets updated, the value for the attribute in the class should be
> updated. The problem is that's not happening the way I thought it
should. Am
> I doing something wrong, or do I have the wrong  idea about the
capability
> of databinding???
> 
> 
> When the "asdf" button is clicked, I'm expecting it to display
what's in the
> lastName field, but based on the updated attribute from the TexInpu.
> 
> package com.viva.model
> {
>  [Bindable]
>  public class RecordData
>  {
>   public var recordID:int;
>   public var firstName:String = 'Douglas';
>   public var middleName:String;
>   public var lastName:String;
>   public var address:String;
>   public var city:String;
>   public var state:String;
>   public var zip:String;
>   public var heightFt:Number;
>   public var heightIn:Number;
>   public var weight:Number;
>   public var hairColor:String;
>   public var eyeColor:String;
>   public var dob:Date;
> 
>   public function RecordData():void {
>    // constructor
>   }
>  }
> }
> 
> <?xml version="1.0" encoding="utf-8"?>
> <mx:VBox
>  xmlns:mx="http://www.adobe.com/2006/mxml";
>  label="Name / Address"
>  width="100%"
>  height="100%">
> 
>  <mx:Script>
>   <![CDATA[
>    import mx.controls.Alert;
>    import com.viva.model.RecordData;
> 
>    [Bindable]
>    public var record:RecordData = new RecordData();
> 
>   ]]>
>  </mx:Script>
> 
>  <mx:HBox>
>   <mx:Form>
>    <mx:FormHeading label="Defendant Name" />
>    <mx:FormItem label="First Name">
>     <mx:TextInput id="firstName" text="{record.firstName}" />
>    </mx:FormItem>
>    <mx:FormItem label="Middle Name">
>     <mx:TextInput id="middleName" text="{record.middleName}" />
>    </mx:FormItem>
>    <mx:FormItem label="Last Name">
>     <mx:TextInput id="lastName" text="{record.lastName}" />
>    </mx:FormItem>
>   </mx:Form>
> 
>   <mx:Form>
>    <mx:FormHeading label="Address" />
>    <mx:FormItem label="Number/Street">
>     <mx:TextInput />
>    </mx:FormItem>
>    <mx:FormItem label="City">
>     <mx:TextInput />
>    </mx:FormItem>
>    <mx:FormItem label="State">
>     <mx:TextInput />
>    </mx:FormItem>
>    <mx:FormItem label="Zip Code">
>     <mx:TextInput maxChars="9" width="100" restrict="0-9" />
>    </mx:FormItem>
>   </mx:Form>
>   <mx:Button label="asdf"
click="mx.controls.Alert.show(record.lastName)" />
>  </mx:HBox>
> </mx:VBox>
>






------------------------ Yahoo! Groups Sponsor --------------------~--> 
Something is new at Yahoo! Groups.  Check out the enhanced email design.
http://us.click.yahoo.com/SISQkA/gOaOAA/yQLSAA/nhFolB/TM
--------------------------------------------------------------------~-> 

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to