converting a drag and drop target from mouse to gesture using action script 3
hi all, have been following tutorial on drag , drop using mouse buttons. need using touch gestures touch , drag.
i have code either need start again or convert code have.
i have movieclips shapes , shape targets. idea correct moviclip dragged correct targets. if movieclip hits correct target stops , if wrong target returns starting position. know can use hit test point confirm moviclips have gone correct targets.
like have code mouse clicks not sure start mobile devices. i'm new coding , thought simple change mouse gestures don't think have enough experience.
if wise member me connect grateful.
i have been using function below. far can tell movieclip stored in variable(item) when clicked on. when released either snaps reg point of target or returns original positon.
item1_mc.addeventlistener(mouseevent.mouse_up, item1release);
item1_mc.addeventlistener(mouseevent.mouse_down, dragtheobject);
function dragtheobject(event:mouseevent):void {
var item:movieclip=movieclip(event.target);
item.startdrag();
var toppos:uint=this.numchildren-1;
this.setchildindex(item, toppos);
}
function item1release(event:mouseevent):void {
var item:movieclip=movieclip(event.target);
item.stopdrag();
if (target1_mc.hittestpoint(item.x,item.y)) {
item.x=target1_mc.x;
item.y=target1_mc.y;
} else {
item.x=orig1x;
item.y=orig1y;
}
};
how convert gesture touch , drag?
there no functional difference between click/drag , touch/drag. mobile browsers automatically convert touch events click events.
the actual problem have mobile browsers don't run as3. need convert entire thing html/javascript.
More discussions in Adobe Animate CC - General
adobe
Comments
Post a Comment