PDA

View Full Version : Combo box


mattia_79
02-12-2004, 10:20 AM
How can i add an item to a combobox??

i set a variable call "element" that contains a value.

i insert in a movie, "result" a combobox "contact".

than i write this as code:

result.contact.AddListenerEvent("Address:", contact);

but it's bad.

thanks

red penguin
02-12-2004, 11:11 AM
Best thing to do is to use an Array of Objects.

arr = [{label:'label one', data:'one'}, {label:'label two', data:null}];
comboBox_1.setDataProvider(arr);

This is a very stripped down version, but as long as you have a ComboBox on the Stage named 'combobox_1', this is fine.

// just populates.
dataProvider = ["Label One","Label Two"];

Look in the help. You can easily loop through incoming data and populate an array of objects for a combobox...

lporiginalg
04-24-2008, 05:58 PM
Hey perhaps someone can answer this for me. I am trying to populate a combobox with numbers from a for loop (it's for people to set their birthday on a form) my code looks like so:

for (i=1; i<=31; i++) {
day.addItem([i]);
}
for (i=1941; i<=2008; i++) {
year.addItem([i]);
}


For some reason it puts a dot after each number :(
Anyone know why this is and how I can fix it?

Cheers,
Lyndon

red penguin
04-24-2008, 06:15 PM
maybe...

addItem(i.toString())

Alternatively you could populate an array of objects and then set the dataProvider for each ComboBox.

lporiginalg
04-24-2008, 09:02 PM
thanks red, when I saw your reply I realized I didn't need the square brackets so first thing I did was remove those and problem solved.

Cheers,
lp