Reputation: 3
I have this very simple program to do for a school project. I'm making a set of games based on the revolutionary war (irrelevant in this matter). This game involves an instance called player pushing a barrel off of a boat. Using my textbook, I have come up with code for a keyboard event that should move the player. The problem I get is that when I try to view my SWF, I get this 5007 error code and the player does not move. I'll post the code below. And I apologize in advance, my professor really just taught us basics and asked us to work with what we have. I think I can figure out the rest of my project if I can get this player to move.
package
{
import flash.display.MovieClip;
import flash.events.KeyboardEvent;
import flash.ui.Keyboard;
public class Main_Character extends MovieClip {
public function Main_Character() {
init();
}
function init():void
{
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
}
public function onKeyDown(event:KeyboardEvent):void
{
if (event.keyCode == Keyboard.LEFT)
{
player.x -= 10;
}
else if (event.keyCode == Keyboard.RIGHT)
{
player.x += 10;
}
else if (event.keyCode == Keyboard.DOWN)
{
player.y += 10;
}
else if (event.keyCode == Keyboard.UP)
{
player.y -= 10;
}
}
}
}
Upvotes: 0
Views: 154
Reputation: 42166
Check your document class
name , and check if all .as
files are saved.
Upvotes: 1