3 Replies Latest reply on Jul 13, 2011 2:28 PM by AlHolden

    Can not change restrict property of TextInput via ActionScript

    AlHolden Level 1

      Please tell me why this does not work, or suggest a workaround.

       

      This debug example should change the TextInput to allow a dash when the box is checked, yes?

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                     xmlns:s="library://ns.adobe.com/flex/spark"
                     xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">

       

          <fx:Script>
              <![CDATA[
                  public function chkClicked():void {
                      if(chk1.selected) {
                          trace('box checked, allow -');
                          ti1.restrict = "0-9.\-";
                      }
                      else {
                          trace('box unchecked, disallow -');
                          ti1.restrict = "0-9.";
                      }
                  }
              ]]>
          </fx:Script>
         
          <mx:VBox>
              <s:CheckBox id="chk1" click="chkClicked()" />
              <s:TextInput id="ti1" width="60" restrict="0-9." />
          </mx:VBox>

       

      </s:Application>

       

      Each of the restrict strings will work when applied directly as a mxml attribute.

       

      Thanks,

      Al