//variables
var hero:MovieClip;
var bg:MovieClip;
var Key:KeyObject = new KeyObject(stage);
stage.addEventListener(Event.ENTER_FRAME,moveCharacter);
hero.gotoAndStop(‘idle’);
bg.visible = true;
//character Movements
hero.scaleX=-1;
function moveCharacter(e:Event):void
//function onenter(keyEvent:KeyboardEvent):void
{
if(Key.isDown(Key.RIGHT))
{
hero.x+=5;
hero.scaleX=-1;
hero.gotoAndStop('walking');
}
else if(Key.isDown(Key.LEFT))
{
hero.x-=5;
hero.scaleX=1;
hero.gotoAndStop('walking');
}
else if(Key.isDown(Key.UP))
{
hero.y-=30;
hero.y+=30;
hero.gotoAndStop('jump');
}
else if(Key.isDown(Key.S))
{
hero.gotoAndStop('slash');
}
else if(Key.isDown(Key.A))
{
hero.gotoAndStop('special');
}
else if(Key.isDown(Key.D))
{
hero.gotoAndStop('thrust');
}
else
{
hero.gotoAndStop('idle');
}
}
function backScroll():void
{
if (hero.walking < stage.stageHeight)
{
back.x+=10;
}
}
help ! actually theres no error but the wrong is I have to press down the keys before it move, like slash. have to press keys for 2 seconds i guess… anyone can help me ???
thnks in advance !