Hide a layer until a key is pressed as2

87 Views Asked by At

How would you hide a layer in as2 until a key is pressed by the user? I'm trying to create a titan fall like game where you can press E to jump to another layer and out of the 'mech' layer

1

There are 1 best solutions below

0
On BEST ANSWER

You can't hide a layer with ActionScript. You must put all your objects in a MovieClip, and do like that:

var keyListener:Object = new Object();

keyListener.onKeyDown = function():Void {
    if (Key.getCode() == 69) myMovieClip._visible = false;
}
Key.addListener(keyListener);