PDA

View Full Version : [AS3] Making ComboBox Label = anothers Label.


Affimage
09-23-2008, 12:31 AM
Hi, I am building a form type of application and there are multiple areas asking questions, and there are ComboBoxes, and along with the comboboxes, there are checkboxes.

If you click the checkboxes, the information from the previous text fields and comboboxes go in the next become 'duplicated'.

Basically I am looking for something like:

checkboxabc.addEventListener(MouseEvent.CLICK, changefields);
function changefields(event:MouseEvent):void
{
textbox1.text = textbox2.text;
comboBox2.selectedLabel = comboBox1.selectedLabel;
}

However this wont work.

caseyctg
10-07-2008, 04:31 AM
I am doing something similar. I think you need to set an array first. I'm kind of stuck though, so don't take my advice as a pro's.

//set array variable and name it myDP
var myDP:Array = new Array();
//Attach ComboBox to myDP
ComboBoxInstanceName.dataProvider = myDP;
//Make the array a variable that references an xml node...can change to //whatever you want to import from xml or a text
var MainArray= this.firstChild.childNodes[i];
//Loop the array
for (var i:Number = 0; i < MainArray.length; i++) {
// These changes to the DataProvider will be broadcast to the list. this is //setup for xml, only I left the xml load script off.
myDP.addItem({label: MainArray,
data: MainArray.firstChild.childNodes[i]});
}

// Add event listener and event handler function to handle the click on the //combobox.
var cbListener:Object = new Object();
cbListener.change = function(evt_obj:Object):Void {
var currentlySelected:Object = evt_obj.target.selectedItem;

//passes combo box selection data onto list.
myList.dataProvider = ComboBoxInstanceName.selectedItems;

};

// Add event listener and event handler function.
var ListListener:Object = new Object();
ListListener.change = function(evt_obj:Object):Void {
var currentlySelected:Object = evt_obj.target.selectedItem;
};
//attach the components to their listener functions
ComboBoxInstanceName.addEventListener("change", cbListener);
myList.addEventListener("change", ListListener);
}

}

caseyctg
01-04-2009, 06:29 PM
should be:

combobox.selectedItem.label