Tony Alves
Flex, .Net, and Fluorine

Flex ComboBox using XML

Thursday, 23 August 2007 16:47 by talves
I needed a way to have a ComboBox be able to load values from an XML file.
Requirements:
  • Needed to be able to load XML with a standard format "label" as the value you see and "data" as the value of the selection.
  • Needed a way to set the selected value, so the correct "label" shows as selected (borrowed).
  • Load the XML dynamically by setting the XML path during runtime.
  • XML list in the ComboBox may change without recompiling the application.
I extended the ComboBox in actionscript and added two new properties to be able to accomplish the requirements.
xmlFile="xml/somefile.xml" sets the files path.
selectedValue="somecode" sets the value of the data to be selected.

Country and State Demo using XMLComboBox
View Source

This example uses Country and State/Province. When you select "United States" as the country, the States xml will load. When you select "Canada" as the country, the Provinces xml will load. The selectedValue can be changed during runtime as in the example using the TextInput component and change event.

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   ,
Categories:   Flex | Examples
Actions:   E-mail | del.icio.us | Permalink | Comments (0) | Comment RSSRSS comment feed

Related posts

Comments

Add comment


(Will show your Gravatar icon)  

  Country flag

[b][/b] - [i][/i] - [u][/u]- [quote][/quote]



Live preview

October 6. 2008 08:05