im planning to create a topdown shooter like in this one http://fc08.deviantart.net/fs27/f/2008/165/8/2/Top_Down_Shooter_Engine_by_ssjskipp.swf
the problem occurs when i need to move my character
in AS2, i could just use
this.onEnterFrame = function(){
if(Key.isDown(Key.UP)){
//moves up
}
and just do it three more times for the other three directions (down,left,right)
but in AS3, i have to use stage.addEventListener(KeyboardEvent.KEY_DOWN, functionname);
function functionname(e:KeyboardEvent){
if(e.keyCode == 38){
//moves up
}
//and create three more for the other three directions
}
but in here multipke keys cant be pressed simultaneously, sometimes there’s also a liitle lag when i tried to change the direction which will be very uncomfortable for the players
i tried to use the mutiple key method in here http://kirupa.com/developer/actionscript/multiple_key_detection.htm
i copied the required code and the Keydetection class, but i got this error
5007: An ActionScript file must have at least one externally visible definition.
i googled about it and it seems the keydetection class need to have the package{ on the top
however, the source code in the example given didn’t need to use the package{
i tried to add the package but it gives this error
1120: Access of undefined property Key.
seems i have to use the import.flash. but i dont know how to make the class work
any way to solve this, or is there an alternate method? thx alot