# Setting Selection of a Combobox?

**URL:** <https://forum.kirupa.com/t/setting-selection-of-a-combobox/260254>\
**Category:** flash\
**Created:** [May 13, 2008, 8:27pm UTC](https://forum.kirupa.com/t/setting-selection-of-a-combobox/260254 "2008-05-13T20:27:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ibsen](https://avatars.discourse-cdn.com/v4/letter/i/c67d28/32.png) [@ibsen](https://forum.kirupa.com/u/ibsen)\
**Post date:** [May 13, 2008, 8:27pm UTC](https://forum.kirupa.com/t/setting-selection-of-a-combobox/260254/1 "2008-05-13T20:27:24Z")

</div>

Is it possible to use AS2 to dynamically set the current state of a ComboBox?

I’m loading variables from an external file, and I need the ComboBoxes to reflect the selection that comes in.

---

<div class="post-metadata">

**Author:** ![Michael\_Chen](https://avatars.discourse-cdn.com/v4/letter/m/b5ac83/32.png) [@Michael\_Chen](https://forum.kirupa.com/u/Michael_Chen)\
**Post date:** [May 13, 2008, 9:10pm UTC](https://forum.kirupa.com/t/setting-selection-of-a-combobox/260254/2 "2008-05-13T21:10:38Z")

</div>

Try this…

```auto

// Add items to the list.
test_cb.addItem({label:"Item 01"});
test_cb.addItem({label:"Item 02"});
test_cb.addItem({label:"Item 03"});
test_cb.addItem({label:"Item 04"});
test_cb.addItem({label:"Item 05"});

// Selects the second item in the combo box.
test_cb **.selectedIndex** = 1;

```

---

<div class="post-metadata">

**Author:** ![ibsen](https://avatars.discourse-cdn.com/v4/letter/i/c67d28/32.png) [@ibsen](https://forum.kirupa.com/u/ibsen)\
**Post date:** [May 15, 2008, 6:21pm UTC](https://forum.kirupa.com/t/setting-selection-of-a-combobox/260254/3 "2008-05-15T18:21:45Z")

</div>

Thank you, Michael, that’ll work brilliantly.

---

<div class="post-metadata">

**Author:** ![jon\_bla](https://avatars.discourse-cdn.com/v4/letter/j/ecc23a/32.png) [@jon\_bla](https://forum.kirupa.com/u/jon_bla)\
**Post date:** [May 15, 2008, 6:59pm UTC](https://forum.kirupa.com/t/setting-selection-of-a-combobox/260254/4 "2008-05-15T18:59:37Z")

</div>

Little more on that:

```auto

my_cb.addItem({data:1, label:"first value"}); // Data is what is actually being send
my_cb.addItem({data:2, label:"second value"});
my_cb.addItem({data:3, label:"third value"});

```
