Action Script3 convert mouseEvents to touchEvents


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?

 

edit have posted in adobe animate forum. hope ok.

the main difference mouse singular while touch events fire off multiple concurrent touch positions. can work either in single touch mode, similar mouse, or handle touch points.

 

have looked adobe examples of handling touch events? here's simple adobe code example of touch/drag:

adobe flash platform * touch , drag



More discussions in Coding Corner


adobe

Comments

Popular posts from this blog

Soustraire une selection

After Effects: could not find dvaeve_dialogs.txt

Illustrator cs6 "Invalid Serial Number"