Skip to main content
Participant
April 27, 2020
Question

Help please. Trying to show Object from hiding using Key Press

So I've try and try, but fail to get it right. I'm trying make Button/Object reveal itself from hiding
Got the button to be false and now Im trying get where a keystroke.. let say "j" to get the button to come true

 

Button.visible = false;

stage.addEventListener(KeyboardEvent.KEY_DOWN, fl_KeyboardDownHandler_4);

function fl_KeyboardDownHandler_4(event:KeyboardEvent):void
{
trace("j" + event.keyCode);
Button.visible = true;
}

 

Clearly I'm doing it wrong. I think I'm suppose to add a event for the hidden object. I've done different ways, but none works. Anyone know how I could get this to work? It be very awesome if anyone can help.

 

Would also like to know if there a way to do it using more than one keystroke. Like is it using + or == ?

 

    This topic is closed to new replies. Start a new post to keep the conversation going.

    1 reply

    Participant
    April 27, 2020

    I figured it out. I was supposely easy, but took me a little while to understand what Keypressed needed in order to work.

     

    Translate