Category Archives: XML

Converting XML to objects using the Flex SimpleXMLDecoder class

Similar to the previous post, “Converting XML to objects using the Flex HTTPService MXML tag“, the following example shows how you can use the decodeXML() method in the SimpleXMLDecoder class to convert an XMLDocument object into an ActionScript Object object.

Full code after the jump.

Continue reading Converting XML to objects using the Flex SimpleXMLDecoder class

Creating two related ComboBoxes

This is a semi-common problem. You have two (or more) ComboBox controls and you want the options in second combo box to change based on the selected item in the first combo box. Or in a real world case, you have a list of countries and a list of provinces/states/regions in that country. When the user changes the value in the country combo box to “Canada”, you would only want to display a list of Canadian provinces/territories in the second combo box. Although if the user selected USA in the country combo box, you would only want to show the American states/regions.

Anyways, enough jibber-jabber, lets see this in action.

Full code after the jump.

Continue reading Creating two related ComboBoxes

Loading XML at run-time using the mx:HTTPService tag

In the previous post we looked at how to load an XML document in at compile-time and have it embedded in our Flex application. But that technique really only works if the XML data in question never changes. What if you had an XML document that was constantly changing on a daily, or hourly, basis. For example, consider an RSS reader application. If the XML was loaded and embedded in the XML document at compile-time, the RSS would never get updated. And while that may be good in some cases (such as a kiosk, or somewhere without an internet connection where you wanted to display static information), in many cases it may not work.

So, lets take a look at using the mx:HTTPService tag to dynamically load an XML file.

Continue reading Loading XML at run-time using the mx:HTTPService tag

Displaying XML data in a DataGrid

OK, hopefully this example is a bit more interesting than a few of my previous ones. Today’s handy tip comes in the form of loading and embedding an XML file in our Flex application at compile-time (as opposed to dynamically loading at run-time, which we’ll save for a future example), and displaying that information in a DataGrid control.

Continue reading Displaying XML data in a DataGrid