haln

06-18-2009, 12:36 AM

Hi, I'm new to actionscript, as you may have figured out, and I need some help with learning how to do drag and drop. I'm trying to make 2 blocks which can be dragged and dropped into 2 boxes, which will have them snap into place. I'm trying to make the redblock move, but it seems each time I try to drag the redblock, I end up dragging the blueblock instead, and it only releases when I click on the redblock again. The blueblock works just fine. Can anybody help me out? I can't figure out what's wrong.

blueblock.onMouseDown = function(){

blueblock.startDrag();

}

blueblock.onRelease = function(){

if ((blueblock._x >60 && blueblock._x <140) && (blueblock._y <140 && blueblock._y >60)) {

blueblock.stopDrag();

blueblock._x=100;

blueblock._y=100;

} else {

if ((blueblock._x >160 && blueblock._x <240) && (blueblock._y <140 && blueblock._y >60)) {

blueblock.stopDrag();

blueblock._x=200;

blueblock._y=100;

} else {

blueblock.stopDrag();

}

}

}

redblock.onMouseDown = function(){

redblock.startDrag;

}

redblock.onRelease = function(){

if ((redblock._x >60 && redblock._x <140) && (redblock._y <140 && redblock._y >60)) {

redblock.stopDrag();

redblock._x=100;

redblock._y=100;

} else {

if ((redblock._x >160 && redblock._x <240) && (redblock._y <140 && redblock._y >60)) {

redblock.stopDrag();

redblock._x=200;

redblock._y=100;

} else {

redblock.stopDrag();

}

}

}

blueblock.onMouseDown = function(){

blueblock.startDrag();

}

blueblock.onRelease = function(){

if ((blueblock._x >60 && blueblock._x <140) && (blueblock._y <140 && blueblock._y >60)) {

blueblock.stopDrag();

blueblock._x=100;

blueblock._y=100;

} else {

if ((blueblock._x >160 && blueblock._x <240) && (blueblock._y <140 && blueblock._y >60)) {

blueblock.stopDrag();

blueblock._x=200;

blueblock._y=100;

} else {

blueblock.stopDrag();

}

}

}

redblock.onMouseDown = function(){

redblock.startDrag;

}

redblock.onRelease = function(){

if ((redblock._x >60 && redblock._x <140) && (redblock._y <140 && redblock._y >60)) {

redblock.stopDrag();

redblock._x=100;

redblock._y=100;

} else {

if ((redblock._x >160 && redblock._x <240) && (redblock._y <140 && redblock._y >60)) {

redblock.stopDrag();

redblock._x=200;

redblock._y=100;

} else {

redblock.stopDrag();

}

}

}