# removeChild problem

**URL:** <https://forum.kirupa.com/t/removechild-problem/283928>\
**Category:** Uncategorized\
**Created:** [March 12, 2009, 4:00pm UTC](https://forum.kirupa.com/t/removechild-problem/283928 "2009-03-12T16:00:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tjsl2](https://avatars.discourse-cdn.com/v4/letter/t/7cd45c/32.png) [@tjsl2](https://forum.kirupa.com/u/tjsl2)\
**Post date:** [March 12, 2009, 4:00pm UTC](https://forum.kirupa.com/t/removechild-problem/283928/1 "2009-03-12T16:00:51Z")

</div>

Hi,

I’m having a problem with removeChild. I’m a newbie to AS3 so my problem is an embarrassingly simple one, but you have to start somewhere.

I’m creating a sprite (\_spHolder1) in the DisplayManager class, then within the same class I’m instantiating another class called StartTrans. Within the StartTrans class I want to delete the sprite \_spHolder1.

I’m slightly confused with the fact that I’m able to trace \_spHolder1 from the StartTrans class, but unable to use removeChild

The error I get is:

Error #1009: Cannot access a property or method of a null object reference.

I’ve stripped it right down to the problematic code.

Any help would be much appreciated.

Cheers,

tjsl2

```auto
package {
	
	import flash.display.*;

	import com.tobylow.display.animation.StartTrans;

	public class DisplayManager extends Sprite {
		
		public var _spHolder1:Sprite;

		public function DisplayManager() {
			
			creatBasicDisplay();
                }

		private function creatBasicDisplay():void{
			
			_spHolder1 = new Sprite();
			addChild(_spHolder1);
			
			startTransition();
		}
		
		private function startTransition():void{
			
			var _startTrans = new StartTrans(_spHolder1);
	}
}

```

```auto
package{
	
	import flash.display.*;
	
	public class StartTrans extends Sprite{
		
		private var _sp1:Sprite;
		
		public function StartTrans(sp1:Sprite):void{
			
			_sp1 = sp1; 
			init();
                }
		
		private function init():void{
		        
                        trace(_sp1);
                        removeChild(_sp1);
			_sp1 = null;
                }
        }
}

```
