1 Reply Latest reply on Apr 21, 2010 6:48 PM by zalda1984

    Problem with TextInput's Enter Event

    zalda1984

      I have met a problem with TextInput's Enter Event. If I set the Flex Compiler->Require Flash Player version to 10, i can not change the TextInput's text property in the Enter Event Handler.Following is the example code:

       

      <?xml version="1.0" encoding="utf-8"?>

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

      <mx:TextInput text="{this.a}" id="txt" x="158" y="272" enter="onEnter(event)" />

      <mx:Script>

      <![CDATA[

      import mx.events.FlexEvent;

       

      [Bindable]

      private var a:String = '';

       

      private function onEnter(e:FlexEvent):void

      {

      this.a = this.a +'11';

      }

       

      private function add():void

      {

      this.a = this.a +'11';

      }

      ]]>

      </mx:Script>

      <mx:Button x="403" y="481" label="Button" click="add()"/>

      </mx:Application>

       

      As you see, I want to change the this.a in the Enter Event handler in order to change the TextInput's text by binding,but it doesnt work. If I set Flex Compiler->Require Flash Player version to 9, it works. I found a method to solve this problem: If I use a CallLater function to change the this.a variable,it works. The code is as follows:

       

      private function onEnter(e:FlexEvent):void

      {

      this.callLater(this.addText);

      }

       

      private function addText():void

      {

      this.a = this.a+'11';

      }