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(KeyListene r);
(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)
KeyListener = new Object();
KeyListener.onKeyDown = function(){
trace("key pressed" + Key.getCode());
}
Key.addListener(KeyListene
(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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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.