I’ve been trying to run some functions in my class every frame and have come up with this code:
class playercam extends MovieClip
{
var ThefocusX:Number=0;
var ThefocusY:Number=0;
var smootherscrollX:Number=0;
var smootherscrollY:Number=0;
private var OldCamY:Number;
private var OldCamX:Number;
private var char:MovieClip;
private var dir:Number;
function playercam(MC:MovieClip, direction:Number)
{
char = MC;
update(MC ,direction);
}
private function onEnterFrame():Void
{
charactercamX();
charactercamY();
}
public function update(MC:MovieClip, direction:Number):Void
{
char._x = MC._x;
char._y = MC._y;
dir = direction;
}
public function StillX():Boolean
{
if( ( (OldCamX + 25) >= _root._x) || ( (OldCamX - 25) >= _root._x) )
{
return true;
}
else
{
return false;
}
}
public function StillY():Boolean
{
if( ( (OldCamY + 25) >= _root._y) || ( (OldCamY - 25) >= _root._y) )
{
return true;
}
else
{
return false;
}
}
private function charactercamX():Void
{
trace("here");
if(dir == 1 && smootherscrollX<=70)
{
smootherscrollX += 5;
}
if(dir == -1 && smootherscrollX>=-70)
{
smootherscrollX -= 5;
}
ThefocusX = char._x + (smootherscrollX) - 360;
OldCamX = _root._x;
_root._x += ( -ThefocusX - _root._x) / 5;
trace(( -ThefocusX - _root._x) / 5);
}//end charactercamX
private function charactercamY():Void
{
ThefocusY = char._y - 270;
OldCamY = _root._y;
_root._y += ( -ThefocusY - _root._y) / 5;
}//end charactercamY
}
I get no errors, but the functions charactercamX and charactercamY are not running every frame. Any one know why?