vendredi 3 mars 2017

How to set drag X limit

I'm working on some draggable/droppable bar.So it's draggable only x because this is select bar.Problem is select button draggable out of stage limit. I want to draggable only in stage limit.I tried some methods hitTestPoint and newshape but it didn't work.

// define lock on y-axis
var LOCKY:Number = secbuton.y;
stage.addEventListener(MouseEvent.MOUSE_MOVE, _mouseMove);
function _mouseMove(e:MouseEvent):void
if(secbuton.y != LOCKY) secbuton.y = LOCKY;
// dragging
secbuton.addEventListener(MouseEvent.MOUSE_DOWN, _mouseDown);
function _mouseDown(e:MouseEvent):void
secbuton.addEventListener(MouseEvent.MOUSE_UP, _mouseUp);
// dropping
function _mouseUp(e:MouseEvent):void
secbuton.removeEventListener(MouseEvent.MOUSE_UP, _mouseUp);

    secbuton.x = levcbk1.x +5  

    secbuton.x = levcbk2.x +5  

Aucun commentaire:

Enregistrer un commentaire