# Help with Error #1009

**URL:** <https://forum.kirupa.com/t/help-with-error-1009/286336>\
**Category:** flash\
**Created:** [April 14, 2009, 3:21am UTC](https://forum.kirupa.com/t/help-with-error-1009/286336 "2009-04-14T03:21:13Z")\
**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 14, 2009, 3:21am UTC](https://forum.kirupa.com/t/help-with-error-1009/286336/1 "2009-04-14T03:21:13Z")

</div>

I’ve started to work with classes and i’ve come across this error:

```auto
TypeError: Error #1009: Cannot access a property or method of a null object reference.
	at Ball$iinit()
	at bouncingBall_CS3_fla::MainTimeline/bouncingBall_CS3_fla::frame1()

```

The following is my class:

```auto
package
{
	import flash.display.MovieClip;
	import flash.events.*;
	import flash.display.*;
	
	public class Ball extends MovieClip
	{
		private var timer:uint = 0;
		private var initPos:Number = 0;
		private var initSpeed:Number = 0;
		private var tehground:MovieClip;
		private var myBall:MovieClip;
		private const decay:Number = .9;
		private const grav:Number = 32 / stage.frameRate;
		
		
		
		public function Ball(ground:MovieClip, ball:MovieClip):void
		{
			tehground = ground;
			myBall = ball;
			timer = 0;
			initPos = myBall.y;
			myBall.addEventListener(Event.ENTER_FRAME, fall);
		}
		
		private function fall(e:Event):void
		{
			timer += 1;
			checkGround();
			myBall.y = initPos + .5 * grav *(timer * timer);
			
		}
		
		private function checkGround()
		{
			if (tehground.hitTestPoint(myBall.x, initPos + .5 * grav * (timer * timer)+1, true))
			{
				myBall.removeEventListener(Event.ENTER_FRAME, fall)
				
				while (!tehground.hitTestPoint(myBall.x, myBall.y-1, true))
				{
					myBall.y++;
				}
				
				initPos = myBall.y;
				timer = 0;
				
				initSpeed = decay * Math.sqrt(Math.abs(2 * (myBall.y - tehground.y)));
				
				myBall.addEventListener(Event.ENTER_FRAME, rise);
			}
		}
		
		private function rise(e:Event):void
		{
			timer += 1;
			
			myBall.y -= .5 * grav * (timer * timer) - initSpeed * timer;
		}
		
	}
	
}

```

And this is on the first frame of flash:

```auto
var myBall:Ball = new Ball(tehground, tehball);

```

tehground and tehball are instance names of 2 different MovieClips.

Any help would be greatly appreciated! Thanks!
