My enterFrame works but onKeyDown gets nothin’
can anyOne see it??
package
{
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.ui.Keyboard;
import flash.events.KeyboardEvent;
public class PlayScreen extends MovieClip
{
var playScreen= new PlayScreenMC();
var ship= new Ship();
//var buttonToIntroScreen:Button1=new Button1("introScreen")
// var customEvent:String=""
public function PlayScreen():void
{
addEventListener(Event.ADDED_TO_STAGE, playGame);
function playGame():void
{
playScreen.scaleX=7;
playScreen.scaleY=7;
playScreen.x=185;
playScreen.y=250;
addChild(playScreen);
playScreen.bumpers_mc.alpha=0;
ship.scaleX=2;
ship.scaleY=2;
ship.x=185;
ship.y=250;
addChild(ship);
stage.addEventListener(Event.ENTER_FRAME,onEnterFrame);
stage.addEventListener(KeyboardEvent.KEY_DOWN,onKeyDown);
stage.addEventListener(KeyboardEvent.KEY_UP,onKeyUp);
trace("eventListeners");//**[COLOR=Red]<<this Works[/COLOR]**
}
function onKeyDown(event:KeyboardEvent):void
{
trace("keyDownY");//**[COLOR=Red]<<<this does Not work[/COLOR]**
switch(event.keyCode)
{
case Keyboard.LEFT:
trace("left");
break;
case Keyboard.RIGHT:
trace("right");
break;
case Keyboard.UP:
trace("up");
break;
}
}
function onEnterFrame(event:Event):void
{
trace("enterFrame")//**[COLOR=Red]<<<this Works[/COLOR]**
}
//function onKeyDowny(event:KeyboardEvent):void
// {
// }
function onKeyUp(event:KeyboardEvent):void
{
}
//buttonToIntroScreen.x=100;
// buttonToIntroScreen.y=100;
// addChild(buttonToIntroScreen);
// buttonToIntroScreen.addEventListener(MouseEvent.CLICK,handleClick);
//trace("menuScreenHere");
//needs buttons that effect :fuel repair goods
//needs to show current weight and efficiency
//needs to show btrace("");ank account
//needs to choose route
//needs a button that starts the level
//start level x
}
//public function handleClick(evt:MouseEvent):void
// {
// //trace("MenuScreenHandleClick");
//// customEvent=buttonToIntroScreen.fireString;
//// trace(customEvent);
//// dispatchEvent(new Event(customEvent,true));
// }
//
}
}