Skip to main content
Known Participant
December 18, 2018
Question

i don't know why my moving code not work

  • December 18, 2018
  • 1 reply
  • 180 views

import flash.events.KeyboardEvent;

stop();

function movecar (event:KeyboardEvent):void{

  if (event.keyCode == 37){

  car.x -=5;

  }

  }

  stage.addEventListener(KeyboardEvent.KEY_DOWN,movecar);

    This topic has been closed for replies.

    1 reply

    JoãoCésar17023019
    Community Expert
    Community Expert
    December 18, 2018

    Hi.

    Your code is correct.

    Are you sure that the instance you're trying to move is actually called "car"?

    You can set the instance name by selecting the object on stage and going to the Properties panel.

    Please see the image below to see the differences between instance properties and symbol properties.

    Regards,

    JC