[COLOR=#000000][FONT=verdana]i have 2 MC(car1,car2)[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]i wanna make move Array with arrow left and right[/FONT][/COLOR]
[COLOR=#000000][FONT=verdana]this my code :
var object:Array = new Array(car1,car2);
[/FONT][/COLOR]
var leftArrow:Boolean = false;
var rightArrow:Boolean = false;
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressedDown);
stage.addEventListener(KeyboardEvent.KEY_UP, keyPressedUp);
stage.addEventListener(Event.ENTER_FRAME, moveMascot);
function keyPressedDown(event:KeyboardEvent) {
if (event.keyCode == 37) {
leftArrow = true;
} else if (event.keyCode == 39) {
rightArrow = true;
}
}
function keyPressedUp(event:KeyboardEvent) {
if (event.keyCode == 37) {
leftArrow = false;
} else if (event.keyCode == 39) {
rightArrow = false;
}
}
function moveMascot(event:Event) {
var speed:Number = 5;
if (leftArrow) {
[COLOR=#000000][FONT=verdana]object[/FONT][/COLOR].x -= speed;
}
if (rightArrow) {
[COLOR=#000000][FONT=verdana]object[/FONT][/COLOR].x += speed;
}
}
my code not work,why??
tanks