# \[Q\] dropTarget with Class extends MovieClip

**URL:** <https://forum.kirupa.com/t/q-droptarget-with-class-extends-movieclip/233467>\
**Category:** flash\
**Created:** [July 24, 2007, 10:10am UTC](https://forum.kirupa.com/t/q-droptarget-with-class-extends-movieclip/233467 "2007-07-24T10:10:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![manfree](https://avatars.discourse-cdn.com/v4/letter/m/f04885/32.png) [@manfree](https://forum.kirupa.com/u/manfree)\
**Post date:** [July 24, 2007, 10:10am UTC](https://forum.kirupa.com/t/q-droptarget-with-class-extends-movieclip/233467/1 "2007-07-24T10:10:56Z")

</div>

Dear all,

The following is a Class called ‘Ball’, just a drag and drop movie clip  
I would like to check that …  
if the Ball has been dropped on/over the OBJECT1.

But i don’t know how to write it in a class  
The OBJECT1 is already created on root and named as ‘object1’

```auto
 
package {
 import flash.display.MovieClip;
 import flash.events.MouseEvent;
 private var holder:MovieClip = new MovieClip();
 public class Ball extends MovieClip {
  public function Ball() {
   this.buttonMode = true;
   this.addChild(holder);
   this.addEventListener(MouseEvent.MOUSE_DOWN, onDragHandler);
   this.addEventListener(MouseEvent.MOUSE_UP, onDropHandler);
  }
 }
 function onDragHandler(e:MouseEvent):void {
  this.startDrag();
 }
 function onDropHandler(e:MouseEvent):void {
  this.stopDrag();
  if (this.dropTarget == root.object1) {
   trace("Hit");
  }
 }
}

```

tried :  
[COLOR=seagreen]if (this.dropTarget == root.object1) {[/COLOR]  
[COLOR=seagreen]trace(“hit”);[/COLOR]  
[COLOR=seagreen]}[/COLOR]  
result:  
[COLOR=red]1119: Access of possibly undefined property OBJECT1 through a reference with static type flash.display:DisplayObject.[/COLOR]

tried:  
[COLOR=seagreen]if (this.dropTarget == MovieClip(root).object1) {[/COLOR]  
[COLOR=seagreen]trace(“hit”);[/COLOR]  
[COLOR=seagreen]}[/COLOR]  
result:  
[COLOR=red]nothing happened[/COLOR]
