How to drag MC and change Another MC's x
hi guys....
trying create mc drag function.my question how change movieclip's x value when drag first mc...
videoslider.addeventlistener(mouseevent.mouse_down, scrollmc);
videoslider.addeventlistener(mouseevent.mouse_up, stopscrollmc);
private function scrollmc(event:mouseevent):void{
event.target.startdrag(false,new rectangle(0,0,500,0));
secondmc.x =event.target.x; //this doesn't work.....
}
private function stopscrollmc(event:mouseevent):void{
event.target.stopdrag();
}
thanks help!
that code should change other object's x property (once per drag interaction). if intend have following dragged objects x value, need incorporate constant adjustment. code below not written class document, can adjust that...
videoslider.addeventlistener(mouseevent.mouse_down, scrollmc);
videoslider.addeventlistener(mouseevent.mouse_up, stopscrollmc);
var eventtarget:object; // allow more global access dragged object
function scrollmc(event:mouseevent):void{
eventtarget = object(event.currenttarget);
eventtarget.startdrag(false,new rectangle(0,0,500,0));
stage.addeventlistener(mouseevent.mouse_move, adjust2ndx);
}
function stopscrollmc(event:mouseevent):void{
eventtarget.stopdrag();
stage.removeeventlistener(mouseevent.mouse_move, adjust2ndx);
}
function adjust2ndx(evt:mouseevent):void {
secondmc.x = eventtarget.x;
}
More discussions in Adobe Animate CC - General
adobe
Comments
Post a Comment