I know I am missing something very simple but I just can't seem to figure it out. So I have my buttons that control a log on the stage like so:
//buttons for main screen left and right
mainScreen.leftBtn.addEventListener(MouseEvent.CLICK, leftButtonClicked);
mainScreen.rightBtn.addEventListener(MouseEvent.CLICK, rightButtonClicked);
private function leftButtonClicked(e:MouseEvent):void
{
if (e.type == MouseEvent.CLICK)
{
clickLeft = true;
trace("LEFT_TRUE");
}
}
private function rightButtonClicked(e:MouseEvent):void
{
if (e.type == MouseEvent.CLICK)
{
clickRight = true;
trace("RIGHT_TRUE");
}
}
Now these control the logs rotation that I have setup in an ENTER_FRAME event listener function called logControls();
like so:
private function logControls():void
{
if (clickRight)
{
log.rotation += 20;
}else
if (clickLeft)
{
log.rotation -= 20;
}
}
What I want to do is when the user presses left or right the log rotates each frame left or right. But what is happening is it only rotates one way and doesnt respond to the other mouse events. What could I be doing wrong?