The last thing to do to get a full Website skeleton is to populate the navigation bar. As we said before, the purpose of this series of tutorials is to create a dynamic Website. For that reason, we will use an external configuration file to populate the menu. SPAS 3.0 provides an easy-to-use mechanism to populate list objects from external XML files. Each list object, such as list boxes or link bars, has a xmlQuery property which can be set with a XMLQuery instance. XMLQuery objects deal with the loading of XML data set and automatically populate the list objects they are binded with.

The following XML file contains the minimal structure for building the menu of our Website:

<?xml version="1.0" encoding="iso-8859-15"?>
<item label="Home" />
<item label="Solutions" />
<item label="Webdesign" />
<item label="Webpublishing" />
<item label="Freeware" />
<item label="Contact" />

The only thing you have to do is to save it at the root of the site with the name menu.xml.

Now we can create a new XMLQuery instance called _menuData and declare the populateMenu() function. (Remember that XMLQuery objects are located inside the org.flashapi.swing.databinding package.)

We link the menu object xmlQuery property with the newly created XMLQuery instance and we use the XMLQuery class load() method to automatically set external menu data at runtime:

private var _menuData:XMLQuery;
private function populateMenu():void {
    _menuData = new XMLQuery();
    _menu.xmlQuery = _menuData;

To populate the menu, we call the populateMenu() function at the end of the createUI() method.