Loading XML information into the ComboBox component
Drag an instance of the ComboBox component onto the stage and name it
CBOLoadSites.
Add the following function to the actions layer, immediately above the
stop action. The function tests that the XML file loaded successfully,
loads the sites and URLs into arrays, creates a default item
and adds the sites and URLs to the ComboBox
component.
function LoadCombo(success) {
if (success) {
//set variables
var BaseNode=thisXML.childNodes[0];
var ComboSites = new Array();
var ComboURLs = new Array();
var ThisNode;
//add a default item to the combo box
CBOLoadSites.addItem("-- select site --");
//get sites information
for (i=0; i
ThisNode = BaseNode.childNodes[i];
ComboSites[i] = ThisNode.attributes["siteName"];
ComboURLs[i] = ThisNode.attributes["siteURL"];
//add to combo box
CBOLoadSites.addItem(ComboSites[i],ComboURLs[i]);
}
}
}
You add a change handler as shown previously in the Adding a change handler
section.