654 Working with External Data
A third sample demonstrates how to create a dynamic menu with XML data. The sample calls
the ActionScript
XmlMenu() constructor and passes it two parameters: the path to the XML
menu file and a reference to the current timeline. The rest of the functionality resides in a
custom class file, XmlMenu.as.
You can find the sample source file, xmlmenu.fla, in the Samples folder on your hard disk.
■ On Windows, browse to boot drive\Program Files\Macromedia\Flash 8\Samples and
Tutorials\Samples\ActionScript\XML_Menu.
■ On the Macintosh, browse to Macintosh HD/Applications/Macromedia Flash 8/Samples
and Tutorials/Samples/ActionScript/XML_Menu.
Using the XML class
The methods of the ActionScript XML class (for example, appendChild(), removeNode(),
and
insertBefore()) let you structure XML data in Flash to send to a server and manipulate
and interpret downloaded XML data.
The following XML class methods send and load XML data to a server by using the HTTP
POST method:
■ The load() method downloads XML from a URL and places it in an ActionScript
XML object.
■ The send()method encodes the XML object into an XML document and sends it to a
specified URL using the
POST method. If specified, a browser window displays
returned data.
■ The sendAndLoad() method sends an XML object to a URL. Any returned information
is placed in an ActionScript XML object.
For example, you could create a brokerage system that stores all its information (user names,
passwords, session IDs, portfolio holdings, and transaction information) in a database.