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’
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]