View Full Version : [AS3] Jig Saw Puzzle Game

01-25-2009, 06:08 PM

Could someone help me please, I am trying to make a drag and drop jig saw game, the fla. attach with this message if you wish to see it.

What I am trying happend happen is

1.drag onto shape
2.match the shape to the hole of a shape
3.If it the wrong shape hole that wrong shape hole will show an "x" underneath it, if it the correct shape hole that shape will show a tick underneath it.

What the the problem is this line


Some one let me know please, How would make the wrong shape show the x underneath it and not the target shape?

Thank you for your help

Kind Regards

Charles : )

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

square_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
square_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
triangle_mc.addEventListener(MouseEvent.MOUSE_DOWN , pickUp);
triangle_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
flower_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
flower_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);
pentagon_mc.addEventListener(MouseEvent.MOUSE_DOWN , pickUp);
pentagon_mc.addEventListener(MouseEvent.MOUSE_UP, dropIt);

function pickUp(event:MouseEvent):void {
reply_txt.text = "";
startX = event.target.x;
startY = event.target.y;

function dropIt(event:MouseEvent):void {
var myTargetName:String = "target" + event.target.name;
var myTarget:DisplayObject = getChildByName(myTargetName);
if (event.target.dropTarget != null && event.target.dropTarget.parent == myTarget){
event.target.removeEventListener(MouseEvent.MOUSE_ DOWN, pickUp);
event.target.removeEventListener(MouseEvent.MOUSE_ UP, dropIt);
event.target.buttonMode = false;
event.target.x = myTarget.x;
event.target.y = myTarget.y;
} else {
reply_txt.text = "Try Again!";
event.target.x = startX;
event.target.y = startY;
if(counter == 4){

reply_txt.text = "Congrats, you're finished!";

square_mc.buttonMode = true;
flower_mc.buttonMode = true;
triangle_mc.buttonMode = true;
pentagon_mc.buttonMode = true;