PDA

View Full Version : KeyCode controlling MovieClips issue



joejozwowski
October 28th, 2007, 04:59 PM
I present to you the problem....

I have two movieClips that are controlled by a series of keyCode functions. The issue I'm running into is that the code that I've designated for each action that the movieClip (up, down, left, right) cannot be executed if the other movieClip is being controlled.

So if I'm pressing the "down" key that controls one movie clip, the other cannot be moved until I release the "down" key.

Is there a way to make sure that the keys I have set aside for one movieClip will not interfere with the key that I have set aside for the other movieClip?

It has been brought to my attention that it may just be a keyboard issue (only allowing so many keystrokes at once) but in this instance it's not the case.

I would just like to ensure that both movieClip can be controlled independently from each other.

Thank you for your time.
JMJ

ArmoredSandwich
October 28th, 2007, 06:49 PM
do you use if(Key.isDown(Key."keycode")){ or are you using some kind of listener.

joejozwowski
October 28th, 2007, 06:57 PM
It's a combination of key.getCode, a switch function to designate which keyCodes do what, and series of custom functions that designate when a key is pressed and if a certain key is pressed. I am using onClipEvent(keyDown), onClipEvent(keyUp) and Key.getCode as a basis for all of these.

StridBR
October 28th, 2007, 08:20 PM
It's a combination of key.getCode, a switch function to designate which keyCodes do what, and series of custom functions that designate when a key is pressed and if a certain key is pressed. I am using onClipEvent(keyDown), onClipEvent(keyUp) and Key.getCode as a basis for all of these.

if all keys are on the same switch, it'll break on the first listed key that is pressed

try breaking your switch in pieces, or using if-else statements

ArmoredSandwich
October 29th, 2007, 09:03 AM
It's a combination of key.getCode, a switch function to designate which keyCodes do what, and series of custom functions that designate when a key is pressed and if a certain key is pressed. I am using onClipEvent(keyDown), onClipEvent(keyUp) and Key.getCode as a basis for all of these.

im not sure but i think thats the problem, you cant see if theres more then 1 key being pushed down. Again, im not sure

you want to let the players decide which keys they use for what. I would personally set it something like player1Up = key.getCode(); and then ingame. if(Key.isDown(Key.player1Up)){ // code }.

You know what im saying?

joejozwowski
October 29th, 2007, 09:38 AM
I kinda figured that had something to do with it. But the one thing I don't get is that in my switch function it lists all the actions the movieClip should perform, but I left out the "default:" switch at the end. So do you think a Key event listener would work better in this situation, and if so, could someone point out a good tutorial on Key event listeners, it's one of the only things I haven't been able to fully grasp yet.