Skip to main content
Known Participant
October 23, 2012
Question

drag contents up down by touch on iphone

  • October 23, 2012
  • 1 reply
  • 516 views

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.

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;

}


This topic has been closed for replies.

1 reply

gus93222Author
Known Participant
October 23, 2012

note : i dont know where did i get this code , cuz i dont know how to deal with it

so dont ask what is what

here is where i got it from

http://forums.adobe.com/message/3918652#3918652