based on your answer serhatsezer I was able to fix the problem, thanks
The main problem I was doing was i was declaring the variables outside the function so it was not getting updated
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.display.Stage;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.geom.Point;
import flash.text.TextFieldAutoSize;
import flash.text.TextField;
import flash.ui.Mouse;
import flash.display.DisplayObjectContainer;
import fl.transitions.Tween;
import fl.transitions.easing.*;
import mochi.as3.*;
//variable declaration
var isRightPressed:Boolean = false;
var isLeftPressed:Boolean = false;
var tweenleft:Tween;
var tweenright:Tween;
// move boat
stage.addEventListener(KeyboardEvent.KEY_DOWN,onKeyboardClick);
stage.addEventListener(KeyboardEvent.KEY_UP,onKeyboardUp);
function onKeyboardClick(e:KeyboardEvent):void
{
if (e.keyCode == Keyboard.LEFT)
{
isLeftPressed = true;
}
if (e.keyCode == Keyboard.RIGHT)
{
isRightPressed = true;
}
}
function onKeyboardUp(e:KeyboardEvent):void
{
if (e.keyCode == Keyboard.LEFT)
{
isLeftPressed = false;
}
if (e.keyCode == Keyboard.RIGHT)
{
isRightPressed = false;
}
}
stage.addEventListener(Event.ENTER_FRAME,loop);
function loop(event:Event):void
{
//variable declrations
var Currpos:Number = boat_mc.x;
var xleft:Number = boat_mc.x - 40;
var xright:Number = boat_mc.x + 40;
if (isRightPressed)
{
tweenright = new Tween(boat_mc, "x", Regular.easeOut, Currpos, xright, 2, true);
trace(boat_mc.x);
}
if (isLeftPressed)
{
tweenleft = new Tween(boat_mc, "x", Regular.easeOut, Currpos, xleft, 2, true);
trace(boat_mc.x);
}
}