View Full Version : Drag and Drop Question

10-05-2011, 07:30 PM
I'm very new to AS3 and I need to build a drag and drop question that has four "hit" areas that have been given instance names of benefit2011001_mc, benefit2011002_mc, benefit2011003_mc, and allPlans_mc. There are a total of 16 answers that need to be dragged and dropped into the "hit" areas and if the "hit" is good, it should stay in the "hit" area. If not, then it should go back to the original location of the answer.

The individual movie clips are:

individual250_mc (matches to benefit2011001_mc)
individualNon750_mc (matches to benefit2011001_mc)
individual2500OOP_mc (matches to benefit2011001_mc)
individualNon5000OOP_mc (matches to benefit2011001_mc)

individual1250_mc (matches to benefit2011002_mc)
individualNon2500_mc (matches to benefit2011002_mc)
individual3000OOP_mc (matches to benefit2011002_mc)
individualNon7500OOP_mc (matches to benefit2011002_mc)

individual2500_mc (matches to benefit2011003_mc)
individualNon5000_mc (matches to benefit2011003_mc)
individual6000OOP_mc (matches to benefit2011003_mc)
individualNon15000OOP_mc (matches to benefit2011003_mc)

lifetimeDays_mc (matches to allPlans_mc)
privateNursing_mc (matches to allPlans_mc)
weightLoss_mc (matches to allPlans_mc)
snfMax_mc (matches to allPlans_mc)

None of the tutorials that I've viewed so far discuss multiple movie clips that are named differently from the "hit" area how to drag them, drop them, and evaluate whether or not there is a match. Any help would be greatly appreciated!!!!!


10-05-2011, 08:38 PM
Hi, I started with this code. I'm also copying this to the AS3 list in case different people view different forums.

var ben2011001Arr:Array = new Array (individual250_mc,individualNon750_mc,individual25 00OOP_mc,individualNon5000OOP_mc);
var ben2011002Arr:Array = new Array (individual1250_mc,individualNon2500_mc,individual 3000OOP_mc,individualNon7500OOP_mc);
var ben2011003Arr:Array = new Array (individual2500_mc,individualNon5000_mc,individual 6000OOP_mc,individualNon15000OOP_mc);
var allPlansArr:Array = new Array (lifetimeDays_mc,privateNursing_mc,weightLoss_mc,s nfMax_mc);

for (var i:uint=0; i <ben2011001Arr.length; i++)
ben2011001Arr[i].addEventListener(MouseEvent.MOUSE_DOWN, drag);
ben2011001Arr[i].addEventListener(MouseEvent.MOUSE_UP, drop);

for (var i:uint=0; i <ben2011002Arr.length; i++)
ben2011002Arr[i].addEventListener(MouseEvent.MOUSE_DOWN, drag);
ben2011002Arr[i].addEventListener(MouseEvent.MOUSE_UP, drop);

for (var i:uint=0; i <ben2011003Arr.length; i++)
ben2011003Arr[i].addEventListener(MouseEvent.MOUSE_DOWN, drag);
ben2011003Arr[i].addEventListener(MouseEvent.MOUSE_UP, drop);

for (var i:uint=0; i <allPlansArr.length; i++)
allPlansArr[i].addEventListener(MouseEvent.MOUSE_DOWN, drag);
allPlansArr[i].addEventListener(MouseEvent.MOUSE_UP, drop);

function drag(event:MouseEvent):void

function drop(event:MouseEvent):void

Right track? How would I evaluate the drag/drop?