Keyboard event problem
- stickman8190
-
stickman8190
- Member since: Mar. 7, 2012
- Offline.
-
- Forum Stats
- Member
- Level 01
- Blank Slate
public function Level(){
addEventListener(Event.ENTER_FRAME, loop);
addEventListener(Event.ADDED_TO_STAGE, onAdded);
spd=5;
}
private function onAdded(event:Event) {
stage.addEventListener(KeyboardEvent.KEY_DOWN,keyIsDown);
}
private function keyIsDown(event:KeyboardEvent) {
if(event.keyCode == Keyboard.RIGHT) {
player_mc += spd;
}
}
I'm using a ActionScript 3 Class File and trying to make a simple keyboard movement but the error keeps popping up
1120: Access of undefined property Keyboard.
(I've never used keyboard movements on a as3 class file)
- MSGhero
-
MSGhero
- Member since: Dec. 15, 2010
- Offline.
-
- Forum Stats
- Supporter
- Level 16
- Game Developer
At 5/1/14 12:07 PM, stickman8190 wrote: I'm using a ActionScript 3 Class File and trying to make a simple keyboard movement but the error keeps popping up
1120: Access of undefined property Keyboard.
(I've never used keyboard movements on a as3 class file)
You have to import the class, the same way that you imported KeyboardEvent.
import flash.ui.Keyboard; - stickman8190
-
stickman8190
- Member since: Mar. 7, 2012
- Offline.
-
- Forum Stats
- Member
- Level 01
- Blank Slate


