actionscript 3 - How to drag and drop multiple objects to specific targets? -
i new as3. of course ignore reset button now. know code big , clunky don't mind understood me.
i trying match yellow ball yellow goal , green green , on.
however every time try drag second object can't, object stuck, hear problem as3/flash , simple way solve drag off screen don't want do.
yellowball.addeventlistener(mouseevent.mouse_down, mousedowny) redball.addeventlistener(mouseevent.mouse_down, mousedownr) blueball.addeventlistener(mouseevent.mouse_down, mousedownb) greenball.addeventlistener(mouseevent.mouse_down, mousedowng) yellowball.addeventlistener(mouseevent.mouse_up, mouseupy) redball.addeventlistener(mouseevent.mouse_up, mouseupr) blueball.addeventlistener(mouseevent.mouse_up, mouseupb) greenball.addeventlistener(mouseevent.mouse_up, mouseupg) resetbutton.addeventlistener(mouseevent.click, reset); addeventlistener(event.enter_frame,enterframehandlerr); function mousedowny(event:mouseevent):void { yellowball.startdrag(); } function mousedownr(event:mouseevent):void { redball.startdrag(); } function mousedownb(event:mouseevent):void { blueball.startdrag(); } function mousedowng(event:mouseevent):void { greenball.startdrag(); } function mouseupy(event:mouseevent):void { yellowball.stopdrag(); } function mouseupr(event:mouseevent):void { redball.stopdrag(); } function mouseupb(event:mouseevent):void { blueball.stopdrag(); } function mouseupg(event:mouseevent):void { greenball.stopdrag(); } function enterframehandlerr(event:event):void{ if(yellowball.hittestobject(yellowhome)){ yellowball.stopdrag(); yellowball.x = int(2000); yellowball.y = int(60); } if(redball.hittestobject(redhome)){ redball.stopdrag(); redball.x = int(425); redball.y = int(60); } if(blueball.hittestobject(bluehome)){ blueball.stopdrag(); blueball.x = int(425); blueball.y = int(275); } if(greenball.hittestobject(greenhome)){ greenball.stopdrag(); greenball.x = int(55); greenball.y = int(275); } } function reset(event:mouseevent):void { yellowball.x = int(250); yellowball.y = int(250); };
Comments
Post a Comment