firewahl
firewahl

Reputation: 1

My AS3 code will not run my animation properly

I want to be able to press any key on my keyboard so as to appear to be typing my specific text. No matter what key is pressed, the same scripted text appears, letter by letter(one per keystroke)/frame by frame. Can anyone help me here? As it stands, my animation just continues to loop unless I hit enter (then it stops until pressed again.)

stop();

var keyList:Object = new Object();
keyList.onKeyUp = function () {
nextFrame();
}
Key.addListener(keyList);

stop();

Using Flash cc-thanks

Upvotes: 0

Views: 50

Answers (1)

Chris Sinclair
Chris Sinclair

Reputation: 116

Your code appears to be AS2 rather than AS3?

If your looking for AS3 functionality, you'll want to do something like listen to the stage for keyboard events, and then have an event handler that progresses the frame.

stage.addEventListener(KeyboardEvent.KEY_DOWN,_handleKeyboardPress);

function _handleKeyboardPress(e:KeyboardEvent)
{
    nextFrame();
}

Your code looks as though it would work if you are publishing to AS2 though?

Upvotes: 2

Related Questions