Non Orphan MovieClip problem

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


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:

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 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?.