• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
Locked
0

Tap or Scroll? Understand the difference in AS3

New Here ,
Jan 30, 2014 Jan 30, 2014

Copy link to clipboard

Copied

Hello everyone, I'm developing apps for iOS with Adobe AIR since years but...I always had this big problem: how to make the app understand if I'm tapping something or if I'm just scrolling it?

In my last product I basically have a scrolling menu with some options to activate. So I need a way to determinate if I'm tapping a MovieClip or just scrolling it. Can you help me?

Thank you so much guys, have a nice day!

TOPICS
Development

Views

464

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jan 30, 2014 Jan 30, 2014

Copy link to clipboard

Copied

I use mouse down and mouse up events with a timer....when mousedown fires....timer starts....a tap would occur if the timer records less then 0.1 seconds....scroll would be longer....timer ends when the mouse up event fires....

?...instead of timer, you could also use a measure of distance from where the original touch took place to when the touch no longer is recorded.....less then a certain distance would represent a tap.....I have used a combo of both tecniques.....I stay away from touch events as they are more intensive on cpu.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 31, 2014 Jan 31, 2014

Copy link to clipboard

Copied

LATEST

I would not agree on using Timer event, instead I would use (and I've been using) this:

sprite.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandler);

var moving:Boolean;

function mouseDownHandler(e:MouseEvent):void

{

  sprite.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveHandler);

  sprite.stage.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandler);

  //record mouseX and mouseY in variable

}

function mouseMoveHandler(e:MouseEvent):void

{

  moving = true;

  //set sprite's coordinates

}

function mouseUpHandler(e:MouseEvent):void

{

  if (moving)

  {

   //it means it is scrolling

  } else

  {

    //it means it is a click only..
  }

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines