Drop&Drag game

Hey,

I want to make a game which will work like i am going to have 6 foodstuff both healthy and unhealthy. When we throw a healthy food on a table we will get a point for it.

I am very confuse how and where to begin. I have searched on google but cant find anything that can helps me out so much

Here i have a code i have tried with, but its not working.

I will be very thankfull if anyone of you can help me.



var startX:Number;
var startY:Number;
var counter:Number = 0;

healthy1.addEventListener(MouseEvent.MOUSE_DOWN, drag);
healthy1.addEventListener(MouseEvent.MOUSE_UP, drop);
healthy2.addEventListener(MouseEvent.MOUSE_DOWN, drag);
healthy2.addEventListener(MouseEvent.MOUSE_UP, drop);
healthy3.addEventListener(MouseEvent.MOUSE_DOWN, drag);
healthy3.addEventListener(MouseEvent.MOUSE_UP, drop);

function drag(event:MouseEvent):void {

	event.target.startDrag(true);
	reply_txt.text = "";
	event.target.parent.addChild(event.target);
	startX = event.target.x;
	startY = event.target.y;
}

function drop(event:MouseEvent):void {
event.target.stopDrag();

	var myTargetName:String = "target" + event.target.name;
	var myTarget:DisplayObject = getChildByName(myTargetName);
	if (event.target.dropTarget != null && event.target.dropTarget.parent == myTarget){
		reply_txt.text = "******";
		
		event.target.removeEventListener(MouseEvent.MOUSE_DOWN, drag);
		event.target.removeEventListener(MouseEvent.MOUSE_UP, drop);
		
		event.target.buttonMode = false;
		event.target.x = myTarget.x;
		event.target.y = myTarget.y;
		counter++;
	} else {
		reply_txt.text = "******";
		event.target.x = startX;
		event.target.y = startY;
	}
	if(counter == 4){
        reply_txt.text = "*******";
    }
}

healthy1.buttonMode = true;
healthy2.buttonMode = true;
healthy3.buttonMode = true;




I I have also been given idea for another different code:
healthy1.healthy = true;
healthy2.healthy = true;

if (event.target.healthy == true)…

and then use hittesting or dropTarget.

But i am not sure how to use this code.

PLz help anyone :frowning: