PDA

View Full Version : [AS2] movement coding errors in action game


newave
01-06-2010, 04:35 AM
Hello,



I am creating a flash lite fighting game using cs3 and as2. I am having some problems with my main characters motion. I found this code from a beatem up tut and simply replaced the instances... Here is the code:

anumari_mc.step=15;
anumari_mc.attack = false;
anumari_mc.stance= 1;
anumari_mc.crouch=false;
keydown=false;

this.onEnterFrame = function()
{
if(anumari_mc.attack==false)
{
if (Key.isDown (Key.RIGHT) )
{
anumari_mc._xscale = 100;
anumari_mc.stance=1;
anumari_mc._x+=anumari_mc.step;
anumari_mc.gotoAndStop("walk_right");
}
else if (Key.isDown (Key.LEFT) )
{
anumari_mc._xscale = -100;
anumari_mc.stance=0;
anumari_mc._x-=anumari_mc.step;
anumari_mc.gotoAndStop("walk_left");
}
else if (Key.isDown (Key.DOWN) )
{
anumari_mc.gotoAndStop("block_left");
anumari_mc.crouch=true;
}
else if (!Key.isDown ())
{
anumari_mc.gotoAndStop("stance");
anumari_mc.crouch=false;
}
}

if (Key.isDown (Key.CONTROL) && keydown==false)
{
anumari_mc.attack=true;
}

if(anumari_mc.attack)
{
if (Key.isDown (Key.DOWN))
{
anumari_mc.gotoAndStop("crouchkick");
}
else
{
anumari_mc.gotoAndStop("punch");
}
}

if (Key.isDown (Key.CONTROL))
{
keydown=true;
}
else
keydown=false;
}

but when I run the test it says:


Statement must appear within onclip event handler --- anumari_mc.step=15;



I used this same code with flash 8 pro with no prob.

neilmmm
01-06-2010, 09:22 AM
you need to put the codeon the frame not on the clip