# Non Orphan MovieClip problem

**URL:** https://forum.kirupa.com/t/non-orphan-movieclip-problem/309566
**Category:** flash
**Created:** [May 18, 2010, 8:46pm UTC](https://forum.kirupa.com/t/non-orphan-movieclip-problem/309566 "2010-05-18T20:46:00Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Kreender](https://avatars.discourse-cdn.com/v4/letter/k/f19dbf/32.png) [@Kreender](https://forum.kirupa.com/u/Kreender)
#### Post date: [May 18, 2010, 8:46pm UTC](https://forum.kirupa.com/t/non-orphan-movieclip-problem/309566/1 "2010-05-18T20:46:00Z")

</div>

Hi, I’m trying to make a custom class for collision detection, this is what I’ve got so far.

```auto

package  
{
    /**
     * ...
     * @author Santiago
     */
    
    import flash.display.DisplayObject;
    import flash.display.BitmapData;
     
    public class CustomCollision
    {
        
        public function CustomCollision() 
        {
            
        }
        
        public function isColliding(target1:DisplayObject,target2:DisplayObject):Boolean
        {
            var target1BitmapData:BitmapData = new BitmapData(target1.parent.width, target1.parent.height, true, 0);            
            var target2BitmapData:BitmapData = target1BitmapData.clone();
            
            // Dibujar en los bitmaps data
            
            target1BitmapData.draw(target1, null, null, null, null, false);
            target2BitmapData.draw(target2, null, null, null, null, false);
            trace(target1.transform.matrix.tx);
            trace(target1.transform.matrix.ty);
            
            return(true);

            
             //dispose de los bitmaps dara
            
            
        }
        
    }

}

```

This does nothing so far, because I get this error:  
“”[Fault] exception, information=TypeError: Error #1009: Cannot access a property or method of a null object reference.  
Fault, Main() at Main.as:163"

This happens when I do:

```auto
var colisionSantiago:CustomCollision;
            var paraNada:Boolean = colisionSantiago.isColliding(movie1, movie2);

```

where movie1 and movie2 are two movieClips recently added to the stage, so they must have a parent, but somehow it doesn’t work.  
I started doing my own class after getting the same error with this class: [http://labs.boulevart.be/index.php/2007/06/08/skinner-collision-detection-in-as3](http://labs.boulevart.be/index.php/2007/06/08/skinner-collision-detection-in-as3) and ironically I’m stuck with the same error. I’m using flashdevelop 3.1.1 and the flex sdk 3.5 for compiling. Any ideas?.
