Link to home
Start Free TrialLog in
Avatar of Thread7
Thread7

asked on

How to simulate a keypress in Flash actionscript 2.

I have the following code in my Flash AS2 project. The trace works fine and the trace tells me what key was pressed. What I need to do though is actually simulate the keypress. (I have a datagrid object and need to make the focus go down one on the list). So I want to simulate pressing key 38 but am not sure how.

KeyListener = new Object();
KeyListener.onKeyDown = function(){
trace("key pressed" + Key.getCode());
}
Key.addListener(KeyListener);


(Just a little background.  I have a third party drag&drop datagrid component.  It doesn't have anything built in to automatically scroll down with the scroll bar.  So I want to press  the down arrow for the user)
ASKER CERTIFIED SOLUTION
Avatar of julianopolito
julianopolito
Flag of Brazil image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Thread7
Thread7

ASKER

If I put a statment such as
KeyListener.onKeyDown();
in my code, yes it will call that function.  However, objects on the stage are not receiving that Keypress.  I think this is on the right track, I just don't know what to pass it.  Ie.
KeyListener.onKeyDown(38);
does not make flash think that key 38 was just pressed.