Search code examples
androidactionscript-3flashflash-cs6

Limit the TouchDrag Object to X axis only


I currently have this code, from Flash CS6 code Snippets:

function fl_TouchBeginHandler(e:TouchEvent):void
{
    e.target.startTouchDrag(e.touchPointID);
}
function fl_TouchEndHandler(e:TouchEvent):void
{
    e.target.stopTouchDrag(e.touchPointID);
}

What I want to do is = limit the draggable OBJECT to be dragged horizontally only. So that it couldn't be dragged UP nor DOWN.

I have searched here in Stack overflow and haven't found any relevant question/answer to this problem. thanks.


Solution

  • Look at Adobe's official , Touch Point ID part , function onTouchMove :

    function onTouchMove(event:TouchEvent) { 
      // ...
        mySprite.x = event.stageX; 
      // ...
    }