Skip to main content
Known Participant
January 26, 2019
Answered

code snippet not working

  • January 26, 2019
  • 2 replies
  • 619 views

i tried to add simple touch and drag code snippet to a symbol for air to ios.

when testing app on iphone x it doesn't work. why?

/* Touch and Drag Event

Allows the object to be moved by holding and dragging the object.

*/

Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

green.addEventListener(TouchEvent.TOUCH_BEGIN, fl_TouchBeginHandler_2);

green.addEventListener(TouchEvent.TOUCH_END, fl_TouchEndHandler_2);

var fl_DragBounds_2:Rectangle = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);

function fl_TouchBeginHandler_2(event:TouchEvent):void

{

event.target.startTouchDrag(event.touchPointID, false, fl_DragBounds_2);

}

function fl_TouchEndHandler_2(event:TouchEvent):void

{

event.target.stopTouchDrag(event.touchPointID);

}

    This topic has been closed for replies.
    Correct answer kglad

    try event.currentTarget instead of event.target

    2 replies

    udikAuthor
    Known Participant
    February 2, 2019

    thank you

    correct

    kglad
    Community Expert
    Community Expert
    February 2, 2019

    you're welcome.

    kglad
    Community Expert
    kgladCommunity ExpertCorrect answer
    Community Expert
    January 26, 2019

    try event.currentTarget instead of event.target

    udikAuthor
    Known Participant
    March 30, 2019

    i thought its ok but still not working:

    /* Touch and Drag Event

    Allows the object to be moved by holding and dragging the object.

    */

    Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;

    sechvi.addEventListener(TouchEvent.TOUCH_BEGIN, fl_TouchBeginHandler_2);

    sechvi.addEventListener(TouchEvent.TOUCH_END, fl_TouchEndHandler_2);

    var fl_DragBounds_2:Rectangle = new Rectangle(0, 0, stage.stageWidth, stage.stageHeight);

    function fl_TouchBeginHandler_2(event:TouchEvent):void

    {

    event.currentTarget.startTouchDrag(event.touchPointID, false, fl_DragBounds_2);

    }

    function fl_TouchEndHandler_2(event:TouchEvent):void

    {

    event.currentTarget.stopTouchDrag(event.touchPointID);

    }