On LEFT

Hi,
this is probably very simple.
I need a code that runs a script if the key "LEFT’ is released, but in an ON handler, not in an IF.
Anyone?

LUster


onClipEvent (keyUp) {
	if (Key.getCode() == Key.LEFT) {
		trace("left");
	}
}

First,excuse me for the late reply and thanks for your reply.
But I ment something completely different.
I ment, you can say:

button.onRelease = function() {

But can you say something like :

LEFT.onRelease?

I mean the key LEFT, but that way Flash will search for a button named “LEFT”

Luster

No you cant do that and i think Voetsjoeba code do works as you want.

But where do we have to paste the script with the things that happen?

Yeah Voetsjoeba’s code is right on target it looks like.

You could also use a listener I beleive,

-Data

You can place this on the main timeline:

this.onKeyUp = function() {
	if (Key.getCode() == Key.LEFT) {
		trace("LEFT key was released");
	}
};
Key.addListener(this);

Yes, but I mean if you have for example "_root.movieclip._x +=10"
where inside that code do you have to paste it?

this.onKeyUp = function() {
        if (Key.getCode() == Key.LEFT) {
_root.movieclip._x +=10;
                trace("LEFT key was released");
        }
};
Key.addListener(this);

Heres a very short code for all direction movement
onClipEvent(load) {
KeyCodes = [Key.RIGHT, Key.LEFT, Key.DOWN, Key.UP];
Properties = ["_x", “_y”];
Numbers = [10, -10, 10, -10];
}

onClipEvent(enterFrame) {
for (TempNum=0;TempNum<=KeyCodes.length;TempNum++) {
if (Key.isDown(KeyCodes[TempNum])) {
this[Properties[Math.floor(TempNum/2)]] += Numbers[TempNum];
}
}
}

I now accept your praise and admiration