Hi,

I don't have the book so couldn't look at the code...I know code is
available somewhere online, but me being lazy :)

However, following code might help you...

###mxBindingTest.mxml###
<mx:Application width="800" height="600"
xmlns:mx="http://www.macromedia.com/2003/mxml"; >

<!-- Form contains user input controls. -->
<mx:Form label="Employee Information">
<mx:FormItem label="First Name">
<mx:TextInput id="firstName" />
</mx:FormItem>
<mx:FormItem label="Last Name">
<mx:TextInput id="lastName" />
</mx:FormItem>
<mx:FormItem label="Department">
<mx:TextInput id="department" />
</mx:FormItem>  
<mx:FormItem label="Email Address">
<mx:TextInput id="email" />
</mx:FormItem>
<mx:FormItem label="Country">
<mx:ComboBox id="countries" >
<mx:dataProvider>
<mx:Array>
<mx:String>India</mx:String>
<mx:String>USA</mx:String> 
</mx:Array>
</mx:dataProvider>
</mx:ComboBox>
</mx:FormItem>
</mx:Form>

<!-- The myEmployee data model -->
<mx:Model id="myEmployee">
<name>
<first/>
<last/>
</name>
<department/>/
<email/>
<country />
</mx:Model>

<!-- Properties of user interface controls are bound to the
myEmployee data model using <mx:Binding> tags -->

<mx:Binding source="firstName.text"
destination="myEmployee.name.first" />
<mx:Binding source="lastName.text"
destination="myEmployee.name.last" />
<mx:Binding source="department.text"
destination="myEmployee.department"/>
<mx:Binding source="email.text" destination="myEmployee.email"/>
<mx:Binding source="countries.value"
destination="myEmployee.country"/>


<mx:TextInput text="{myEmployee.country}"/>


</mx:Application>



Notice how combobox box is bound to a Model and Model is bound to
TextInput...

-abdul 

-----Original Message-----
From: Tom Fitzpatrick [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, March 15, 2005 6:01 AM
To: [email protected]
Subject: [flexcoders] ComboBox databinding


I'm trying to create an application based on the LoanCalculator example in 
the Webster/McLeod book.

Everything's working fine for simple bindings between text inputs on a form 
and the value object. Where I'm having trouble creating a databinding 
between a comboBox in the form and the value object. When the user selects 
an item in the comboBox it should be stored as a string in the value object.

What's the way to accomplish this? All the value object variables are 
public, as in the book example.

Specifically, what would the <mx:Binding/> statement look like? A simple 
example would be even better.

Thanks.

- Tom







Yahoo! Groups Links









Reply via email to