PDA

View Full Version : ups and downs



crinity
June 18th, 2003, 06:34 PM
i under stand how you can do key.isdown(key.RIGHT) is there something so like when i let go it will trigger something so like when i press right it animates running and when i let go he is animated standing thanks alot :)

Raydred
June 18th, 2003, 07:39 PM
is this in a movie clip? or wheres the code that fires the Key.Isdown ??

crinity
June 18th, 2003, 07:41 PM
yes i have like a movie clip

guy
-idle
-run
-shoot

those 3 movie clips are in the guy movie clip i asumed thats how you did it im probly rong but what i want it to do is if im holding right the guy runs and when i let go it plays idle

is that more clear sorry about before

Raydred
June 18th, 2003, 07:42 PM
im just wondering where you code is for the key press.

is it on a Movieclip? in a onClipEvent

?

Raydred
June 18th, 2003, 08:02 PM
ok if the code is in a Clip Event... try this code..

assuming the "standing Still" mc is in frame1, and the running is in frame 2 (thats waht i'd use etc) =)


----------------------------
onClipEvent(enterFrame){

if(Key.isDown(13)){
this.gotoAndStop(2);
}else{
this.gotoAndStop(1);
}
-----------------------------------------------

crinity
June 18th, 2003, 08:05 PM
thanks i under stand
now i have one more question is this correct

onClipEvent(enterFrame){

if(Key.isDown(key.right)) && (key.isdown(key.control)) {
this.gotoAndStop(3);
}else{
this.gotoAndStop(1);
}

Clown Staples
June 19th, 2003, 06:40 PM
that is a frame based way to do it... looks good, except RIGHT might have to be capitalized.

another way is event based

function onKeyDown(){
if(Key.getCode()==Key.RIGHT)
gotoAndStop(3);
}
function onKeyUp(){
if(Key.getCode()==Key.RIGHT)
gotoAndStop(1);
}
Key.addListener(this);