Why won't my player move
So i'm starting a new game (more of a benchmark for myself really though) to test how well I remember the material. So I had planned to test it bit by bit but I can't event get my player to move! I realize in a scroller you move the background mainly, not the player, but before I did that I tested to see if my player would move. He wouldn't. I'm not getting any errors, warning, output readings. Any ideas?
package
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.ui.Keyboard;
import flash.events.MouseEvent;
import flash.events.KeyboardEvent;
public class Main extends MovieClip
{
var vx:int;
public function Main()
{
init();
}
function init():void
{
//initilize variables
vx = 0;
//add Event Listeners
stage.addEventListener(KeyboardEvent.KEY_DOWN, onKeyDown);
stage.addEventListener(KeyboardEvent.KEY_UP, onKeyUp);
addEventListener(Event.ENTER_FRAME, onEnterFrame);
}
function onKeyDown(event:KeyboardEvent):void
{
if (event.keyCode == Keyboard.LEFT)
{
vx = -5;
}
else if (event.keyCode == Keyboard.RIGHT)
{
vx = 5;
}
}
function onKeyUp(event:KeyboardEvent):void
{
if (event.keyCode == Keyboard.LEFT || event.keyCode == Keyboard.RIGHT)
{
vx = 0;
}
}
function onEnterFrame(event:Event):void
{
//Move the player
player.x += vx;
}
}
}
