hello there im working on air for ios project and ive got some touch and drag contents using as3
using this code i can drag a moviclip file up and down on screen of any device
how ever , when dragging lets say the end of moviclip was on top of the edge of screen if you keep dragging moviclip will go over the screen and cant touch it no more .
can any one help me to set an x y value where at certain point dragging goes off , ummm like if you drag up when the end of the movieclip will stop at middle of the screen and you cant drag up no more , the opposite if you drag down.
Code:var ease:int = 6; var targY:int = dragMe.y; var drag:Boolean = false; var ptY:Number = 0; dragMe.addEventListener(Event.ENTER_FRAME, dragHandler, false, 0, true); dragMe.addEventListener(MouseEvent.MOUSE_DOWN, downHandler, false, 0, true); stage.addEventListener(MouseEvent.MOUSE_UP, upHandler, false, 0, true); function dragHandler(e:Event):void { if (drag) { targY = mouseY + ptY; } e.target.y += (targY - e.currentTarget.y) / ease; } function upHandler(event:MouseEvent):void { drag = false; } function downHandler(e:MouseEvent):void { ptY = e.currentTarget.y - mouseY; drag = true; }




Reply With Quote