5 Replies Latest reply on Oct 19, 2007 11:48 AM by kglad

    Detecting keystrokes from within a class

    trigger2160
      Hello again. I seem to be permently on here at the moment. Trying to do advanced things thats the trouble. I have started to try and program "properly" in flash which means using classes. i have a class file and this is imported into an fla file. in the fla file i create some objects from this class. 1 thing the class does is it has a movieclip inside it (which is passed in the constructor)and this movieclip is assigned onpress and onrelease methods. but i also want the movieclip to do something when the space bar is pressed. i have tried to implement this by adding the movieclip as a listener to the Key class. but the strange thing is it will only then do 1 line of my code in the onKeyDown function of the movieclip. it won't do a function if i put that inside the onKeyDown function. my code is below. shape is the movieclip. before now i have detected keystrokes by using onClipEvent (enterFrame) but this has to be on the movieclip itself (i think) and i am trying to get around duplicating code. any help would b much appreciated.

      trigger2160