views:

1089

answers:

2

I'm new to Flash, and I can't seem to do this simple action.

(I'm using ActionScript 3.0)

I created an input text box in my editor. The instance name is "test". In my Action editor I have this:

import flash.events.Event;
this.test.addEventListener(Event.PASTE, pasteHandler);

function pasteHandler(e:Event)
{
    trace("blaaaaaaaaaagh");
}

When I run it, it doesn't detect any of my paste events, whether I'm doing Ctrl+V or right-click+paste. If I use another event, like MouseEvent.CLICK, it detects it fine. In fact, I don't think any Event.XXX events (like COPY, INIT, etc.) are detected (at least from the ones I tried). All of the MouseEvent and KeyboardEvent events seem to work fine.

What am I doing wrong?

+1  A: 

Hi there,

TextField objects do not dispatch clear, copy, cut, paste, or selectAll events. Sorry for the bad news!

Tyler.

Tyler Egeto
Aw. I guess I can work around that.
You could extend it and add that functionality your self (you would have to monitor which keys are pressed) but the suggestion below is good too.
Tyler Egeto
A: 

I'd listen for Event.CHANGE since pasting is going to change the field.

Joel Hooks