1
votes

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?

4
Your code is correct, where have you put it? Timeline? Custom class? - amoeba
frame 1 of my actions layer on the main timeline - Andrew
this is bizarre ... what IDE do you use? it seems like something is really broken ... - back2dos
just using flash...now I'm including my as file instead of keeping all the code on frame one, but I'm still getting the same error - Andrew

4 Answers

2
votes

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.

1
votes

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.

0
votes

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);

0
votes

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.