Hi,
I have a Flash animation of an old arcade cabinet.
While using the arrow keys on the keyboard I want my animation to show Left, Right, Up, Down and Normal states for each way you can move the joystick. I have pictures of the joystick for each direction.
I have created a movie clip with 5 frames(joystick_mc), each one with the different direction in its own frame. I put stop() in the 1st frame.
My code to make the switch happen is:
joystickListener = new Object();
joyStickListener.onKeyDown = function() {
if (Key.isDown(Key.LEFT)) {
joystick_mc.gotoAndPlay("left");
}
if (Key.isDown(Key.RIGHT)) {
joystick_mc.gotoAndPlay("right");
}
if (Key.isDown(Key.UP)) {
joystick_mc.gotoAndPlay("up");
}
if (Key.isDown(Key.DOWN)) {
joystick_mc.gotoAndPlay("down");
}
};
joyStickListener.onKeyUp = function() {
trace("re-centre joystick");
};
Key.addListener(joyStickListener);
My problem is nothing happens. I put trace("LEFT"); instead of joystick_mc.gotoAndPlay("left"); and it outputs fine, but trying to get it to play the frame "left" in my movie clip is not happening.
I have tried _root.joystick_mc.gotoAndPlay and _level0.joystick_mc.gotoAndPlay and nothing happens.
Can someone help me and let me know what I'm doing wrong.
Thank you for your time,
J
I have a Flash animation of an old arcade cabinet.
While using the arrow keys on the keyboard I want my animation to show Left, Right, Up, Down and Normal states for each way you can move the joystick. I have pictures of the joystick for each direction.
I have created a movie clip with 5 frames(joystick_mc), each one with the different direction in its own frame. I put stop() in the 1st frame.
My code to make the switch happen is:
joystickListener = new Object();
joyStickListener.onKeyDown = function() {
if (Key.isDown(Key.LEFT)) {
joystick_mc.gotoAndPlay("left");
}
if (Key.isDown(Key.RIGHT)) {
joystick_mc.gotoAndPlay("right");
}
if (Key.isDown(Key.UP)) {
joystick_mc.gotoAndPlay("up");
}
if (Key.isDown(Key.DOWN)) {
joystick_mc.gotoAndPlay("down");
}
};
joyStickListener.onKeyUp = function() {
trace("re-centre joystick");
};
Key.addListener(joyStickListener);
My problem is nothing happens. I put trace("LEFT"); instead of joystick_mc.gotoAndPlay("left"); and it outputs fine, but trying to get it to play the frame "left" in my movie clip is not happening.
I have tried _root.joystick_mc.gotoAndPlay and _level0.joystick_mc.gotoAndPlay and nothing happens.
Can someone help me and let me know what I'm doing wrong.
Thank you for your time,
J