Stoping and starting animation based on pressing space.
Hello i am a beginner at action script so this should be fairly easy to answer. Basically i want the default setting to stop the animation stop(); and then when space is held to play();
Here's what i have:
stage.addEventListener(KeyboardEvent.KEY_DOWN, KeyPressed);
stage.addEventListener(KeyboardEvent.KEY_DOWN, KeyNotPressed);
function KeyPressed(evt:KeyboardEvent):void {
if (evt.keyCode==Keyboard.SPACE){
play();
}
}
function KeyNotPressed(evt:KeyboardEvent):void {
if (evt.keyCode!=Keyboard.SPACE){
stop();
}
}
Thanks for the help