Reputation: 79021
I'm trying to capture the ENTER event of a TextInput like so:
a_txt.addEventListener(fl.events.ComponentEvent.ENTER, aEnter);
function aEnter(ComponentEvent):void
{
//...
}
There's 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'm getting this compile error:
1120: Access of undefined property fl.
What am I doing wrong?
Upvotes: 3
Views: 4766
Reputation: 1779
I think you want the textInput
event, rather than the enter
.
The enter
event fires when the user presses the Enter/Return key. The textInput
event fires whenever the user types, deletes, or pastes.
Hope that helps.
Upvotes: 0
Reputation: 972
Think that you want the textEvent then tie this to your normal
function aEnter(e:TextEvent):void {
if (evt.text == "\n") {
evt.preventDefault();
// Do some thing else??
}
}
Upvotes: 1
Reputation: 5563
I am not sure. I always use an 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 an argument name "e" to the function call declaration.
Upvotes: 2