Search tutorials
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 < BaseNode.childNodes.length; 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.
| » Level Intermediate |
|
Added: 2002-08-13 Rating: 7.85 Votes: 26 |
| » Author |
| Applications Developer Marconi Australia |
| » Download |
| Download the files used in this tutorial. |
| Download (369 kb) |
| » Forums |
| More help? Search our boards for quick answers! |
-
You must have javascript enabled in order to post comments.


Comments
There are no comments yet. Be the first to comment!