if(Key.isDown) to be used in a button
Hi guys! Please help me T_T
I am making a android game that has a left and right movement.. I made two buttons for the left and right movements.
What i want is to make my character move when I press the left/right button, i don't need to use keyboard movements..
So how can i make my character move using the left/right button.
These are my codes actionscript 3.0:
import flash.events.Event;
hero.gotoAndStop('still');
stage.addEventListener(Event.ENTER_FRAME,onenter)
function onenter(e:Event):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 hero.gotoAndStop('still');
}
