Problem with variables.
Hi,
I was trying to use arrows keys for navigation. I got 12 frames to be navigated. So thought up the following code.
var position=0;
stage.addEventListener(KeyboardEvent.KEY_UP, moveRight);
function moveRight(e:KeyboardEvent):void {
switch (e.keyCode) {
case Keyboard.LEFT :
if(position>0)
{
prevFrame();
position--;
trace(position);
}
break;
case Keyboard.RIGHT :
if(position<=12)
{
nextFrame();
position++;
trace(position);
}
break;
}
==================================
The problem is :
If I press a right , position = 1, then if i click a left position becomes -1. why ?
Plz help.