Tutorials Home
What's New
Top Rated
Submit
myTutes
Random!
Loading a ComboBox from a file
Author: Sas Jacobs
| Website: http://www.sasjacobs.com |
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.
| » Level Intermediate |
|
|
Added: : 2002-08-13
Rating: 7.64 Votes: 25
Hits: 2138
|
| » Author |
|
Applications Developer
Marconi Australia
|
| » Download |
|
Download the files used in this tutorial.
|
|
Download (369 kb)
|
|
Get conversion and unzipping tools
for PC and Mac here!
|
| » Forums |
|
More help? Search our boards for quick answers!
|
|
Please rate this tutorial, 10 is the top rating, you can also click the
comments link to read/write a review.
|
|
|