Hello all,
I have a problem, as a newcomer to AS3. I'm looking to be able to pick up one of 36 movieclips on the stage, and drag it to a hotspot. If it lands on the hotspot, then it does something, otherwise it just gets dropped.
How do I dynamically change the "target_mc" to be whichever movieclip I select?
This code works fine, but that's because eventlistener is set-up explicitly for a given mc.
Code:// sprites import caurina.transitions.*; var drag_mc:MovieClip = energy_sprites.play_wave; var target_mc:MovieClip = energy_sprites.hotspot_sea; drag_mc.addEventListener(MouseEvent.MOUSE_DOWN,beginDrag); function beginDrag(e:MouseEvent):void { stage.addEventListener(MouseEvent.MOUSE_MOVE,moveMC); stage.addEventListener(MouseEvent.MOUSE_UP,endDrag); } function endDrag(e:MouseEvent):void { stage.removeEventListener(MouseEvent.MOUSE_MOVE,moveMC); if (drag_mc.hitTestObject(target_mc)) { Tweener.addTween(drag_mc,{x:mouseX, y:mouseY, time:1, transition:"easeIn"}); trace("HIT ME"); } else { Tweener.addTween(drag_mc,{x:mouseX, y:mouseY, time:1, transition:"easeIn"}); } stage.removeEventListener(MouseEvent.MOUSE_UP,endDrag); } function moveMC(e:MouseEvent):void { Tweener.addTween(drag_mc,{x:mouseX,y:mouseY,time:0.5,transition:"easeIn"}); e.updateAfterEvent(); }
Thanks a million for any thoughts on this.
![]()




Reply With Quote
