I have an array of 8 movie clips which can be dragged and dropped onto an MC that is their common hitObject.
I would like whichever mc is being dragged to be added as the child of the hitObject MC when it is dropped, however I am having troubles setting up the code.
Currently, I can only have one specific instance added as a child of the hitObject MC because I don't know what to write inside the addChild() parameter aside from a specific instance name (neither "e.target" nor the array name are acceptable).
Here's my code --any and all help will be most appreciated:
Thanks in advance!Code:var redArray:Array = [red,red1,red2,red3,red4,red5,red6,red7]; redArray.forEach(setupDrag); function setupDrag(dragger:MovieClip, index:int, array:Array):void { dragger.addEventListener(MouseEvent.MOUSE_DOWN, dragRed); dragger.buttonMode=true;} redArray.forEach(setupDrop); function setupDrop(dropper:MovieClip, index:int, array:Array):void { dropper.addEventListener(MouseEvent.MOUSE_UP, dropRed); dropper.buttonMode=true;} function dragRed(e:Event):void{ e.target.startDrag();} function dropRed(e:Event):void{ e.target.stopDrag(); if (e.target.hitTestObject(drawer_mc)) { drawer_mc.addChild(red1); // THIS LINE IS MY PROBLEM --WHAT TO REPLACE red1 WITH? red1.y=10; } }




Reply With Quote
