ActionScript 3 Newb: TextInput enter an event?

I am trying to capture a TextInput input event as follows:

a_txt.addEventListener(fl.events.ComponentEvent.ENTER, aEnter);

function aEnter(ComponentEvent):void 
{
    //...
}

There is probably something in these docs http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/fl/controls/TextInput.html#event:enter
which I don't quite understand because I get this compilation error:

1120: Access of undefined property fl.

What am I doing wrong?

+3
source share
3 answers

I'm not sure. I always use the import statement instead of qualifying with package names. Try adding:

import fl.events.ComponentEvent;

and then change your code to:

a_txt.addEventListener(ComponentEvent.ENTER, aEnter);

function aEnter(e:ComponentEvent):void 
{
    //...
}

Note. I also added the argument name "e" to the function call declaration.

+2
source

, , textEvent

function aEnter(e:TextEvent):void {
    if (evt.text == "\n") {
       evt.preventDefault();
       // Do some thing else??
    }
}
+1

, textInput, enter.

The event enterfires when the user presses the Enter / Return key. An event is textInputfired whenever a user types, deletes or inserts.

Hope this helps.

0
source

Source: https://habr.com/ru/post/1711511/


All Articles