Search code examples
flashactionscript-3

textfield will not clear, as3


Is there a way to clear a textfield when all else fails? This is from a very long document I can't post. The textfield is on stage and worked fine until this call. Looking for best guess:)
Thanks

There's no error, I just can change text

public function cx(e:MouseEvent):void{
//VARIABLE THAT EFFECT THESE TEXTFIELDS
V1 = 0;
V2 = 0;
tx_.text  = " ";
//PROBLEM TEXT
txt_.text = " ";
}

Tried:
FocusEvent, but it didn't work

Hmmm:
Maybe there's a killswitch for textfields


Solution

  • t is the instance name of a text field on the stage.

    t.addEventListener( FocusEvent.FOCUS_IN, hf );
    
    function hf(e:FocusEvent):void
    {
    t.text = "";
    }
    

    that code worked for me. Maybe check the text field is not under another display object that is also waiting for mouse events and stuff.