# Help with onEnterFrame inside a Class

**URL:** <https://forum.kirupa.com/t/help-with-onenterframe-inside-a-class/286479>\
**Category:** flash\
**Created:** [April 16, 2009, 3:11am UTC](https://forum.kirupa.com/t/help-with-onenterframe-inside-a-class/286479 "2009-04-16T03:11:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Thefox14](https://avatars.discourse-cdn.com/v4/letter/t/b77776/32.png) [@Thefox14](https://forum.kirupa.com/u/Thefox14)\
**Post date:** [April 16, 2009, 3:11am UTC](https://forum.kirupa.com/t/help-with-onenterframe-inside-a-class/286479/1 "2009-04-16T03:11:33Z")

</div>

I’ve been trying to run some functions in my class every frame and have come up with this code:

```auto
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?
