PDA

View Full Version : plz reply!!!!!! (MOVING LINK)


lord_of_uo
03-24-2006, 01:07 PM
look here to see the problem:

www.zeldavideos.4t.com/link_test.swf (http://www.zeldavideos.4t.com/link_test.swf)

hold the arrow keys down for more than a second and link has a seizure!!!!!

heres the code i put for it:


onClipEvent(enterFrame)
{
if(Key.isDown(Key.RIGHT)){
this._x +=5;
}
}

onClipEvent(enterFrame)
{
if(Key.isDown(Key.LEFT)){
this._x -=5;
}
}

onClipEvent(enterFrame)
{
if(Key.isDown(Key.UP)){
this._y -=5;
}
}

onClipEvent(enterFrame)
{
if(Key.isDown(Key.DOWN)){
this._y +=5;
}
}

on(keyPress "<Right>")
{
gotoAndPlay("walk_right");
}

on(keyPress "<Left>"){
gotoAndPlay("walk_left");
}

on(keyPress "<Up>"){
gotoAndPlay("walk_forward");
}

on(keyPress "<Down>"){
gotoAndPlay("walk_backward");
}

i put in the main character clip all the clips for walking in all directions and put a stop command after each clip

and on each clip.


what did i do wrong?

how do i correct this problem?

Scottae
03-25-2006, 01:32 AM
Try this:

on (keyPress "<Left>") {
trace ("LEFT");
}

That's why

lord_of_uo
03-25-2006, 11:54 PM
srry dude,


but it didnt work.

perhaps you can type a full action script thing that corresponds with mine,

or maybe tell me where to put the line in on the action script.

Scottae
03-26-2006, 12:31 AM
Uhm........that wasn't a fix. That was to point out why your script isn't working. The trace (http://livedocs.macromedia.com/flash/8/main/00001778.html) function is meant as a debugger. When you put that trace action with your key press actions (in this case I just stuck it under the left key press), you will see that the trace action is called once initially while holding down the left arrow key. Then a second later it starts spewing out left after left in the output window. This is the reason your guy is having a seizure. Because this action is constantly calling the gotoAndPlay and telling your guy to play the first frame of that particular animation. But since it gets called so fast, it never has a chance to totally run through the entire animation. As soon as it trys to go to the next frame, the left key press action is telling it to go to the first frame of the animation sequence. So the problem is with the on key press actions on your clip. You need to find another way to trigger the animation so it is only called one time when a user presses the arrow keys.

lord_of_uo
03-26-2006, 12:34 AM
how do you do that?

am i stupid?

is it right infront of me?

8/\ )

Scottae
03-26-2006, 01:13 AM
how do you do that?
am i stupid?
is it right infront of me?
Well, I wouldn't attach code to objects (http://livedocs.macromedia.com/flash/8/main/00001657.html). It's just bad practice and hard to keep up with. I would use the Key (http://livedocs.macromedia.com/flash/8/main/00002294.html) class instead. Use the onEnterFrame (http://livedocs.macromedia.com/flash/8/main/00002490.html) method instead of the onClipEvent enterFrame. As far as figuring how to make it work.....that's your job. Check out Tile Based Games (http://www.tonypa.pri.ee/tbw/index.html) for more info.

FlashMove
03-26-2006, 03:53 AM
hi lord of uo, i have a flash 5 version which you can use for your game. It is compatible with flash mx too.
Flash 5 multiple rectangle collision with character key capture motion (http://flashmove.com/forum/showthread.php?t=24793)