actionscript 3 - Evaluating whether ComboBox.SelectedIndex is greater than -1 (no selection) in AS3 -


i want evaluate if user has selected in combobox can magic new combobox below that. read elsewhere selectedindex value -1 equivalent combobox being untouched user based assumptions on this.

here code:

function displaycarbs(event:mouseevent):void {             _ingredientwizard.visible = false;             _categorycarbs = new categorycarbs();             addchild(_categorycarbs);             'positioning'             _categorycarbs.x = stage.stagewidth / 2 - _categorycarbs.width / 2;             _categorycarbs.y = stage.stageheight / 2 - _categorycarbs.height / 2;             _categorycarbs.btn_goback.addeventlistener(mouseevent.click, addnewingredient)             addchild(mycombobox);             mycombobox.prompt="choose carbs";             mycombobox.x= _comboboxxposition;             mycombobox.y = _comboboxyposition;             mycombobox.width = _comboboxwidth;             mycombobox.height = _comboboxheight;             mycombobox.dataprovider = new dataprovider(myitems);                trace("test1");             if (mycombobox.selectedindex > -1) {                 trace("test2");                 addchild(mycombobox);                 mycombobox.y = _comboboxyposition + _subsequentcomboboxincrement;                 mycombobox.x = _comboboxxposition;                 mycombobox.width = _comboboxwidth;                 mycombobox.height = _comboboxheight;              }         } 

unfortunately second trace doesn't reach output window, , can't think what's wrong if statement, or possibly i'm being bit thick!

you're testing mycombobox.selectedindex less -1.

instead, test of following:

  • selectedindex == -1
  • selectedindex < 0
  • selectedindex <= -1

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -