|
-
textbox OnChange in AS3.0 not work?
Code:
txt1.addEventListener(Event.CHANGE, setText);
function setText(e:Event):void {
txt3.text="changed";
}
but I tried and did not work, txt3 is never set as changed, see if I put txt1.Text = "test" should automatically trigger the listen but it does not happen ever. I do not know where is the problem?!
-
KoolMoves Moderator
As I recall "setting" text doesn't trigger it only triggers on user interaction. Not sure what the fix is though
-
KoolMoves Moderator
You could try dispatching the event when you change the text yourself
dispatchEvent(new Event(Event.CHANGE, true));
-
Thanks, I think I'll have to study to develop custom events then.
-
up to my .as in code
It works fine for user entered text...
txt1.addEventListener(TextEvent.TEXT_INPUT, setText);
function setText (e:TextEvent):void {
txt3.text="changed";
}
But what you ask for is an oddity IMO. If you are programtically setting the text, the need for a text change listener is moot anyway as you KNOW you are changing the text (after all you wrote the code to set it) and would (I would assume) also add code to notify whatever needs to be notified that you have set it. A listener makes sense (and I assume Actionscript is setup this way as it relates to text change events) only when you need to detect text entered in a way you could not possibly forsee or when they might do so (for instance the end user entering something at any given time). In your case you KNOW when you are setting it so it's odd you would need to detect that as it is initiated by your code. Making sense?
Last edited by Chris_Seahorn; 09-09-2009 at 02:53 AM.
-
Resolved
Chris_Seahorn, Magnificent thus worked very well. Thanks for your help.
-
up to my .as in code
Glad to help
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|