XML Connector

 <  Day Day Up  >  

So far in this chapter, we have manually processed XML data. Although it is important to fully understand how to do this, there are shortcuts that will automatically parse the XML and convert it to ActionScript objects for you. This process is especially useful when the data in the XML is used to populate a Flash MX 2004 component. These components are designed to employ automatic databinding, which means that the data from an XML file will automatically display in a component, such as a list box, without having to parse the data. The remainder of this chapter takes a look at the XML Connector component.

N OTE

Databinding is covered in greater detail in Chapter 14.


XML Communications Simplified

You can use the XMLConnector component to connect to an external XML document. After the XML is available in the Flash document, it can directly bind to properties within the document. The XMLConnector can communicate with components in your application using data binding features of the authoring tool (on the Stage), or components can be associated with the XMLConnector data through ActionScript code.

The first step to binding visual elements with XML data is to specify a schema , which is the structure of the XML document that identifies the data elements in the document to which you can bind. The schema appears in the Schema tab in the Component Inspector panel. The schema identifies the fields in the XML document that are bound to user interface component properties in your application. You can manually create the schema through the Component Inspector or use the authoring environment to create one automatically.

The authoring environment will accept a copy of the external XML document to which you are connecting as a model for the schema.

Although the XMLConnector component has properties and events like other components, it has no runtime visual appearance. Figure 12.9 shows an example of using an external XML file to build a schema within the authoring environment.

Figure 12.9. Establishing the schema for an XMLConnector component.

graphics/12fig09.jpg

Binding XML Data

After the XML is available in the Flash document, it can directly bind to properties in the document. Databinding with components is covered in greater detail in Chapter 14.

 <  Day Day Up  >  


Object-Oriented Programming with ActionScript 2.0
Object-Oriented Programming with ActionScript 2.0
ISBN: 0735713804
EAN: 2147483647
Year: 2004
Pages: 162

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net