Highlighted

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

Community Beginner ,
Apr 27, 2020

Copy link to clipboard

Copied

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 == ?

 

Views

25

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

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

Community Beginner ,
Apr 27, 2020

Copy link to clipboard

Copied

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 == ?

 

Views

26

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Apr 27, 2020 0
Community Beginner ,
Apr 27, 2020

Copy link to clipboard

Copied

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

 

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Apr 27, 2020 0