PDA

View Full Version : populate comboBox on another frame


dke01
03-20-2005, 11:49 PM
Hi All,

I have a comboBox embeded within several mc objects. The comboBox is on frame 2 of its parents parents mc. I can't figure out how to populate the comboBox when the mc instace its contained in isn't in the first frame.
I have tried

_root.myObject.another_mc.gotoAndPlay(2);
_root.myObject.another_mc.popup_mc.myCombo.addItem ("aItem",1);
_root.myObject.another_mc.gotoAndPlay(1);

But that doesn't work
Thanks.

billstoudt
03-21-2005, 03:10 PM
why not put the code in frame 2 of the clip along with the combo box?

dke01
03-21-2005, 10:29 PM
Thanks.

The code populating the comboBox is being called from the root level when flash first starts the comboBox is getting its values from an XML file and has to populate 10 other comboBoxes with the same data. That is why I do add the comboBoxs items once in root instead of in frame 2 of the mc that contains the comboBox to save me reading the XML or the array 10 times.

billstoudt
03-22-2005, 01:59 PM
well to answer your question originally you cant do that.

I would store the XML data into an array then when the comboBox is isntaciated,write a function to loop through the array to populate the comboBox.
[EDIT]
hope this code helps

europeArray = new Array();
boxData = new XML();
boxData.ignoreWhite = true;
boxData.onLoad = function() {
tempNode = boxData.firstChild.firstChild;
placeMarkerNode = boxData.firstChild;
while (tempNode != undefined) {
tempArray = new Array();
tempArray[0] = tempNode.attributes.name;
tempArray[1] = tempNode.attributes.link;
tempNode = tempNode.nextSibling;
europeArray.push(tempArray);
}
placeMarkerNode = placeMarkerNode.nextSibling;

};
function populateEurope() {
for (var i = 0; i<=europeArray.length-1; i++) {
europeComp.addItem(europeArray[i][0]);
}
}

boxData.load("xml/countries.xml");
europeReturnHandler = function () {
getURL(europeArray[europeComp.getSelectedIndex()][1]);
};

when you want to populate the box call the populateEurope(); function.

.

dke01
03-23-2005, 04:39 AM
Thanks for you help I will have to do that next time. I was kind of running out of time for this project so for a work around I just placed the comboBox in the first frame and moved it of the stage so it will never be displayed on the screen

Thanks
Again