Hey guys, I just joined the forum because I’m having trouble with a project. I want to have certain keys on a keyboard correspond to a trumpet movie clip on the stage. I’ve gotten to the point where the valve goes down if you press any key on the keyboard, but I want it to only work if you press a specific key. I know that this was pretty simple in AS2 with the Key.isDown function, but I’m looking for a way to do it with AS3. Here’s the code that I have so far-
function reportKeyDown(event:KeyboardEvent):void
{
valve1_mc.gotoAndStop(“down”);
}
stage.addEventListener(KeyboardEvent.KEY_DOWN, reportKeyDown);
function reportKeyUp(event:KeyboardEvent):void
{
valve1_mc.gotoAndStop(“up”);
}
stage.addEventListener(KeyboardEvent.KEY_UP, reportKeyUp);
Thanks for your help!