Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Linking Keys to goToAndRun

Status
Not open for further replies.

ZernanToledo

Programmer
Aug 8, 2006
3
0
0
IE
Hi

I've developing a small visual piece for a band, in which I want the arrow keys to trigger different animations. Its quite simple, but I'm new to flash and aren't sure what I'm doing wrong.

The code I've written is...
------------------------
stop();

fscommand("fullscreen", "true");

if (Key.isDown(Key.RIGHT)) {
gotoAndPlay(1);
} else if (Key.isDown(Key.DOWN)) {
gotoAndPlay(10);
} else if (Key.isDown(Key.UP)) {
gotoAndPlay(20);
} else if (Key.isDown(Key.LEFT)) {
gotoAndPlay(30);
}
-----------------------------------

At the moment the error I'm getting is "access of undefined property Key". The script runs fine without the if loop, but the errors also cause the various stop() sections to break.

Thanks for the help
 
Try:
Code:
...
onEnterFrame = function ():Void {
	if (Key.isDown(Key.RIGHT)) {
		gotoAndPlay(1);
	} else if (Key.isDown(Key.DOWN)) {
		gotoAndPlay(10);
	} else if (Key.isDown(Key.UP)) {
		gotoAndPlay(20);
	} else if (Key.isDown(Key.LEFT)) {
		gotoAndPlay(30);
	}
};
...

Kenneth Kawamoto
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top