|
-
target movieclip from document class
hi
i am making a drag drop game.
i created a doc class for the dragged items .
i want to make the hit test with some movie clips on the stage but inside the class they are not seen by there names.
how to perform my hit test
this is my code,and target1_mc &target2_mc are movie clips on the stage
package {
import flash.display.MovieClip;
import flash.events.MouseEvent;
import flash.text.TextField;
public class recipeMC extends MovieClip {
private var startX:Number;
private var startY:Number;
private var counter:Number=0;
public function recipeMC() {
this.mouseChildren = false;
this.buttonMode = true;
this.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
this.addEventListener(MouseEvent.MOUSE_UP, dropIt);
}
private function pickUp(event:MouseEvent):void {
this.startDrag(true);
this.parent.addChild(this);
startX = this.x;
startY = this.y;
}
private function dropIt(event:MouseEvent):void {
this.stopDrag();
if (this.hitTestObject(event.target.target1_mc)
||this.hitTestObject(event.target.target2_mc) ) {
this.removeEventListener(MouseEvent.MOUSE_DOWN, pickUp);
this.removeEventListener(MouseEvent.MOUSE_UP, dropIt);
this.buttonMode = false;
this.x = myTarget.x;
this.y = myTarget.y;
counter++;
} else {
//reply_txt.text = "Try Again!";
this.x = startX;
this.y = startY;
}
}
}
}
can any one help???
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|