Skip to main content
Participant
August 21, 2018
Question

Problems with jump function when moving from Adobe Flash to Animate

  • August 21, 2018
  • 1 reply
  • 713 views

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();

}

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
August 21, 2018

there's no difference between the actionscript 3 (that works in flash) and the way it would work in animate.

you have some other (than actionscript) problem.

start debugging by looking for an error message when testing in animate and, if there is none, using the trace function.

Participant
August 21, 2018

Thank you so much for the speedy reply!

It's really strange because I have several student projects (and my own) that work perfectly when I open them with the older Flash but not with Animate. There's no change in the code. That's what made me wonder if there were any differences (e.g, in function names, or if I have to import any slightly different modules) with Animate.

JoãoCésar17023019
Community Expert
Community Expert
August 22, 2018

Hi.

Is it possible that you're using an HTML (Canvas) document?