Problems with jump function when moving from Adobe Flash to Animate
I am having difficulty with my ActionScript code. It used to work fine in Adobe Flash but now I have had Animate installed instead it's stopped working. Has anyone had similar problems?
It's the jumping code
stage.addEventListener(KeyboardEvent.KEY_DOWN, jump);
function jump(e:KeyboardEvent):void {
jumpman_mc.play();
}
(This is taken from Colin Maxwell's Jumpman Flash game Jumpman - Adobe Flash games tutorial for beginners )
This is the whole code:
import flash.events.KeyboardEvent;
stop();
var health=20;
health_txt.text=health.toString();
var score=0;
score_txt.text=score.toString();
stage.addEventListener(Event.ENTER_FRAME, gameloop);
function gameloop(e:Event): void{
crate_mc.x-=20;
if (crate_mc.x<-100) {
crate_mc.x=650;
score++;
score_txt.text=score.toString();
}
if (jumpman_mc.hitTestObject(crate_mc)) {
health--;
health_txt.text=health.toString();
if (health<=0) {
stage.removeEventListener(Event.ENTER_FRAME, gameloop);
stage.removeEventListener(KeyboardEvent.KEY_DOWN, jump);
gotoAndStop(1, "Scene 4");
}
}
}
stage.addEventListener(KeyboardEvent.KEY_DOWN, jump);
function jump(e:KeyboardEvent):void {
jumpman_mc.play();
}