O'Reilly logo

Professional Adobe® Flex® 3 by Joe Berkovitz, David Hassoun, Andrew Trice, Tom Sugden, Todd Prekaski, Jun Heider, Peter Ent, Joseph Balderson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 30. Working with Data

This chapter starts the discussion on ActionScript 3.0 language features and Flex framework elements that are available to the modern Flex 3 developer for working with data. The items that will be covered are:

  • XML

  • The Collections API

  • Associative arrays/the Dictionary class

  • Repeaters

XML

The Extensible Markup Language (XML) is a very prevalent means of describing, transferring, and storing data. If you create a Flex application via an MXML editor, you are using a custom declarative language that is based on XML. If you create an application that consumes a SOAP-based Web Service, you receive XML. If you create a configuration file to be distributed with your Flex application, there is a good chance that you will use XML.

Quick XML Primer

For those of you new to XML, let's talk about how XML is constructed before proceeding. If you need to use XML, you have to keep in mind that it needs to be well formed. If the XML you are using is not well formed, the XML parser will choke, and either your application will not compile or it will throw runtime exceptions.

XML is composed of nodes in a hierarchical tree structure. This structure consists of exactly one root node and zero to many child nodes, or more specifically, zero to many XML elements. In the following example, the root node <players/> has two immediate children, each an XML element of type <player/>:

<?xml version="1.0" encoding="UTF-8"?> <players> <player> <category>battery</category> <position>pitcher</position> ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required