Hi, I’ve been having a problem using comboboxes to read from a php script. I want to use around 6 different comboboxes to control a number of different movie clips. I have everything working fine reading from 1 combobox using the following code:
php script:
<?php
$NameArr = array("Headphones", "Sunglasses", "Hat");
$DataArr = array("headphones", "sunglasses", "hat");
for($i=0;$i<count($NameArr);$i++) {
$data[] = $NameArr[$i].":".$DataArr[$i];
}
print implode("
", $data);
?>
Flash:
[AS]
//Create a new instance of the LoadVars object
myVars = new LoadVars();
//Load the text file
myVars.load(“loadCombo.php”);
//Run this when the data has loaded
myVars.onData = function(raw) {
//Split the loaded text into an array by newline
tmp = raw.split("
“);
//Loop through the array
for(var i=0;i<tmp.length;i++) {
//make a new array from each element of the first array splitting on the | symbol
tmp2 = tmp*.split(”:");
//Add an item to the comboBox for this element of the text file
myCombo.addItem(tmp2[0], tmp2[1]);
}
}
//Selection - Select MC
mycombo.setChangeHandler(“onChange”);
onChange=function()
{
_root.man[selected]._visible = false;
selected = mycombo.getValue();
_root.man[selected]._visible = true;
}
function traceCombo(com) {
trace (“Selected Data: " + com.getSelectedItem().data);
trace (“Selected Label: " + com.getSelectedItem().label);
trace (”--------------------------------------”);
}
[/AS]
Now I’m having trouble figuring out what would be the best way to go about reading to multiple comboboxes without creating a number of different functions? Would I be able to redefine the current function to load text into multiple comboboxes from my php script? I’m not sure how to sort out my arrays either.