# Cannot access a property or method of a null object reference

**URL:** <https://forum.kirupa.com/t/cannot-access-a-property-or-method-of-a-null-object-reference/318609>\
**Category:** Uncategorized\
**Created:** [January 25, 2011, 7:26am UTC](https://forum.kirupa.com/t/cannot-access-a-property-or-method-of-a-null-object-reference/318609 "2011-01-25T07:26:13Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wuzel](https://avatars.discourse-cdn.com/v4/letter/w/71e660/32.png) [@wuzel](https://forum.kirupa.com/u/wuzel)\
**Post date:** [January 25, 2011, 7:26am UTC](https://forum.kirupa.com/t/cannot-access-a-property-or-method-of-a-null-object-reference/318609/1 "2011-01-25T07:26:13Z")

</div>

Hello,

I have a drag drop routine, with the dropTarget consisting of a sprite with a label containing text on it. The problem is that depending on the mouse cursor position on the item being dragged, the drop registers either with the intended target Sprite, or with the textField of the Label on the Sprite.

Is there a neat way of finding out what class the drop target is? My attempt gives me the following error.

“Cannot access a property or method of a null object reference”

private function mouseUpStopDrag(e:MouseEvent):void  
{  
var \_valueText:String;  
var \_test:Boolean;  
var \_dropTarget:Object;

```
        e.currentTarget.stopDrag();        
        if (e.currentTarget.dropTarget)            
        {
            _dropTarget = e.currentTarget.dropTarget;                
            _test = (_dropTarget is NumberBlock);                
            while (_test == false) {    
                _dropTarget = dropTarget.parent;
                _test = (dropTarget is NumberBlock);                                        
            }    
            trace(_dropTarget);                            
        }

```

Thanks in advance
