Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Keyboard class not working with CS4 AS3?

New Here ,
Sep 02, 2015 Sep 02, 2015

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");

               

                }

           

           

           

           

        }

       

    }

   

   

    }

TOPICS
ActionScript
318
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Sep 02, 2015 Sep 02, 2015

you forgot to import it:

import flash.ui.Keyboard;

Translate
Community Expert ,
Sep 02, 2015 Sep 02, 2015
LATEST

you forgot to import it:

import flash.ui.Keyboard;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines