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)
Adobe FlashWeb DevelopmentProgramming

Avatar of undefined
Last Comment
Thread7

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
julianopolito

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
Thread7

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.

I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck