2 May 2011
In this exercise you will learn how to customize Flex components and bind them to data to create an auto-generating email address (see Figure 1).
In this exercise you will learn how to:
In this section you will use data binding to populate the employee email address based on the employee's first and last name.
FormItem container with the label property First Name:.id property firstName:<s:FormItem label="First Name:">
<s:TextInput id="firstName" width="196"/>
</s:FormItem>
label property lastName:.id property lastName:.<s:FormItem label="Last Name:">
<s:TextInput id="lastName" width="196"/>
</s:FormItem>
label property assigned to Email:.text property to the value of the firstName and the lastName text properties, separating the values with a period. Append @xyzcompany.com to the end of the text property value so that a full email address is displayed.<s:FormItem label="Email:">
<s:TextInput text="{firstName.text}.{lastName.text}@xyzcompany.com" width="196"/>
</s:FormItem>
You should see the Email field populate with an email address based on the firstName and lastName TextInput controls (see Figure 2).
Note that the email address is created with a space in it (see Figure 3).
You should see that editing the email address does not affect the first and last name values (see Figure 4). This is an example of one-way binding.
In this exercise you learned how to create and reuse a Flex custom component and bind data. In the next exercise you will use an XML file to populate the Employee Portal: Vehicle Request Form with dynamic data.
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.