actionscript 3 - Conditional IF Statements in AS3 -


i've written function respond event listener in separate function:

edit: updated working code.

       function greyoutitems(event:event):void {          if (disablecheckbox.selected) {             mycombobox.alpha = 0.5;              mycombobox.enabled = false;             trace("hide combobox success");         }         if (disablecheckbox.selected == false) {             mycombobox.visible = true;             mycombobox.enabled = true;             trace("visible");         }     } 

the first if statement works well, hiding combobox when user clicks on checkbox, want user able uncheck same checkbox , make combobox visible again.

ideally, rather setting alpha property 0, i'd prefer if combobox "greyed out" although haven't yet found property so.

your conditionals always true because setting them value in conditional. "=" "assigning" properties only. "==" "equivalent to". if (disablecheckbox.selected = true) sets selected property true , way conditional works, because set value, marked true statement.

function greyoutitems(event:event):void {     if (disablecheckbox.selected == true) {         mycombobox.alpha = 0;         trace("success");     }     if (disablecheckbox.selected == false) {         mycombobox.alpha = 1;         trace("revisible");     } } 

in case, should have used else instead of second conditional, however. else statement run faster @ runtime (since doesn't have check second condition, runs else if conditions false). not enough noticeable, adds if doing many times


Comments

Popular posts from this blog

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

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

keyboard - Smiles and long press feature in Android -