Forum Moderators: open
Combo Box is populated with this:
var myData:XML = new XML ();
myData.ignoreWhite = true;
myData.load ("Data.xml");
myData.onLoad = function (success:Boolean):Void
{
if (success)
{
var data:XMLNode = this.firstChild;
var children:Array = data.childNodes;
var numItems:Number = children.length;
for (var i:Number = 0; i < numItems; i++)
{
var child:XMLNode = children[i];
var name:String = child.attributes.name;
var URL:String = child.attributes.URL;
comboBox.addItem (name,URL);
}
}comboBox.selectedIndex=default_indx //This value is set via HTML
}
Here's an example of what the XML looks like:
<villa name="Selection #3" URL="theurl.html" default_indx="2"/>
For some reason it reads the default_indx variable using FlashVars in the HTML, but it woun't read the default_indx variable through the XML file.
Any ideas?
Thanks!
comboBox.selectedIndex=3;
The value of the fourth item in your XML will be displayed.
If the selected index needs to be set based on user input, you need to send the value trough the URL.
Did that help or did I misunderstood what you are trying to do?
This method works, but instead of setting the default_indx in the HTML (which is hardcoded) I want to set the index through the XML file, which is still hard-coded but easier to adjust than separate HTML files. If I can set the default in the XML I can make the adjustments in the single XML file, rather than go to every HTML file and making the change.
Currently, if I want to add an item between 2 current items I'd need to adjust each of the HTML files and re-set their default_indx values. If I could do this in XML I can make the adjustments to the single XML file.
Make sense?
Thanks for your help! Please let me know if you have any other ideas.