Skip to main content
Participant
September 2, 2015
Answered

Keyboard class not working with CS4 AS3?

  • September 2, 2015
  • 1 reply
  • 354 views

I am starting out using Action Script on flash cs4 and found out that whenever I try to use the Keyboard class e.g Keyboard.DOWN I always get "1120: Access of undefined property Keyboard."

Sorry if this has answered before but I cannot seems to find similar question. Here is a very simple AS3 I created trying to play around with the keyboard. Please do help me

package {

   

    import flash.display.*;

    import flash.events.*;

   

   

    public class Main extends MovieClip{

       

        public function Main(){

           

           

                stage.addEventListener(KeyboardEvent.KEY_DOWN, movements);

               

               

                function movements(event:KeyboardEvent){

               

                if(event.keyCode == Keyboard.LEFT);

                trace("success");

               

                }

           

           

           

           

        }

       

    }

   

   

    }

This topic has been closed for replies.
Correct answer kglad

you forgot to import it:

import flash.ui.Keyboard;

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
September 2, 2015

you forgot to import it:

import flash.ui.Keyboard;