6 Replies Latest reply on Nov 29, 2010 2:38 PM by Flex harUI

    How to use binding but also leave a textinput or dropdown blank on initial display?

    JoshBeall Level 1

      Hi All,


      I'm using Flex 4's 2-way binding, and it's extremely useful.  However, one issue I've been running into is when I bind to a variable that is an integer or boolean value.  E.g., consider an int variable "numberOfStudents" and a textinput that is then setup like this:


      <s:TextInput text="@{numberOfStudents}" />


      This works great, but the text field will have a value of 0 in it when the user first visit it.  A similar thing will happen if you have a true/false dropdown list that is bound to a boolean value.


      What I want to do is have no value (blank input, or a dropdownlist with no value selected).  This is what you would get if you were not using binding.


      I'm thinking one way to do this would be with nullable types--just give the variable a default value of "null" and then render "null" as blank on the textinput.


      But int and Boolean are not nullable types in ActionScript, so that won't work.  Any other suggestions?