Reputation: 238777
I have an input text box with the instance name of input_txt and a dynamic text field named output_txt. I'm trying to do something with the dynamic field when the user has entered text into the input field. So far, this is what I have:
input_txt.addEventListener(TextEvent.TEXT_INPUT, update);
function update(event:TextEvent):void {
output_txt.text = "foobar";
}
I don't know if this is valid ActionScript 3.0. I am getting an error that says "the class 'TextEvent' could not be loaded." What am I doing wrong?
Upvotes: 1
Views: 891
Reputation: 3259
Check to see what results you get using
TextEvent.TEXT_INPUT
vs
Event.CHANGE
I had issues with the TEXT_INPUT lagging user update by one character, so I switched to the CHANGE event.
Upvotes: 0
Reputation: 571
You are propably working in a Actionscript 2.0 .fla.
Create new file > Actionscript 3.0
You don't need to import on timeline scripts, just put the textboxes and your original code and you'll propably be fine.
Upvotes: 2
Reputation: 95519
Perhaps you're missing "import flash.events.TextEvent"? Also, you should probably put your code in an action script file (*.as), rather than putting it within a specific frame.
Upvotes: 1
Reputation: 111
I've done something similar. But I listened to the CHANGE event instead. You can try that- it's a bit tricky since it can be thrown sometimes when the field isn't actually changed.
so listen to (Event.CHANGE, update);
Upvotes: 0