Moving an object with keypresses

  1. Open basicMouse
  2. Drag a piece of cheese from the library onto the stage (Ctrl-L to open library)
  3. Name the mouse, mouse, and the cheese, cheese, and the dynamic text box, winning, in the properties panel
  4. Add the code to make the keys move the mouse movie clip.
  5. Create a control layer for the actionscript (a new, empty layer on top)
  6. In frame 1 put this code:
    if(mouse.hitTest(cheese))
       winning.text = "got it";
    else
       winning.text = "keep trying";
  7. In a keyframe in frame 2 put the code
    gotoandPlay(1); 
  8. Place a static frame in the second frame of the timeline for the mouse, text and cheese. (Right-click the frame on the timeline and Insert>Frame)

RUN AND TEST YOUR MOVIE.

Top Grade: Use the code to figure out what key controls this movement so that you can program the I,O,K,L keys to move the mouse diagonally up/left, up/right, down/left, down/right