actionscript 3 - Need to move this Object in one direction -


i trying move seatbelt object on horizontal plane. have posted did far. it's not working out because seems once press button seat belt able move towards right side , mouse_up doesn't work. can guide me on how go doing this?

 seatbelt.addeventlistener (mouseevent.mouse_down, prsing);     seatbelt.addeventlistener (mouseevent.mouse_up, lfting);     seatbelt.addeventlistener (mouseevent.mouse_move, mving);         function prsing (e:mouseevent){     posx= seatbelt.x ;         posy = seatbelt.y ;         mouseclick = 1;       }     function mving (e:mouseevent) {         if (mouseclick == 1) {         seatbelt.x = mousex ;         }     }      function lfting (e:mouseevent){         seatbelt.x = posx;         seatbelt.y = posy;         mouseclick =0;      } 

so intended functionality able drag seatbelt along x-axis , on release go original position?

you need change mouse_up , mouse_move listen stage rather seatbelt. because possible release button when no longer on seatbelt , function never gets called. stage receive event.

stage.addeventlistener(mouseevent.mouse_up, lifting); stage.addeventlistener(mouseevent.mouse_move, moving); 

i not sure declaring mousex variable if after dragging functionality alter listener to:

   function moving (e:mouseevent) {         if (mouseclick == 1) {         seatbelt.x = e.stagex;         }     }  

Comments