Home > Adobe AIR, Adobe Flash, Xuland > Flex: Capturing long-touch events on Android & iOS mobile devices

Flex: Capturing long-touch events on Android & iOS mobile devices

In building the mobile dating app Xuland, one of its key features will be the ability to add many profile photos. Your admirers can tap each photo from a list, see the larger version and vote on whether they like it or not.

The thing is, because buttons are typically over-sized on mobile devices to make them fat-finger friendly, it leave little room on the screen for many of them. You could utilize the off-screen menu option on Android but iOS devices lack this seemingly basic feature. Instead you could design your app to have contextual popup menus appear when holding or pressing down on an icon, button or other object on the screen.

Unfortunately, the current version of Flex (4.5) doesn’t support a long-touch or long-click event from what I can see, but it was easy enough to simulate one using a timer:

private var timer:Timer;
private var confirmPopup:ConfirmPopup;
private function onTouchBegin():void
	timer=new Timer( 1000 );
	timer.addEventListener( TimerEvent.TIMER, onTimerComplete );
private function onTimerComplete( event:TimerEvent ):void
	confirmPopup=ConfirmPopup.open( "delete photo?" );
	confirmPopup.addEventListener( ConfirmPopup.CONFIRMED, onDeletePhotoConfirmed );
private function onDeletePhotoConfirmed( event:Event ):void
	//put additional photo deletion logic here
public function onTouchEnd():void
	timer.removeEventListener( TimerEvent.TIMER, onTimerComplete );

And the MXML…

<s:Image id="image"
	source="{ xyzSource }"
	mouseUp="onTouchEnd()" />

Essentially what happens here is that once the user touches a photo, the timer activates and starts ticking. If the user at any time during the timeout period takes his finger off the photo, the timer is stopped, otherwise when the timer reaches is preset delay, it opens a confirmation popup prompting the user to take some action.

Here’s the results:

Categories: Adobe AIR, Adobe Flash, Xuland Tags:
  1. Pavel fljot
    September 26th, 2011 at 09:00 | #1

    This spring I’ve started a project called Gestouch that simplifies gestures recongnition — the long press is of course one of them.

    Project sources and wiki on github https://github.com/fljot/Gestouch
    Quick introduction video http://www.youtube.com/watch?v=NjkmB8rfQjY

  2. January 27th, 2014 at 02:41 | #2

    Hiya! Quick question that’s completely off topic. Do you know how to make your site mobile friendly?
    My web site looks weird when browsing from my apple iphone.
    I’m trying to find a theme or plugin that might be able to correct this issue.

    If you have any recommendations, please share. Appreciate it!

  3. March 7th, 2014 at 00:22 | #3

    I almost never comment, but i did a few searching and wound
    up here Flex: Capturing long-touch events on Android & iOS mobile devices | eonflex.com.
    And I actually do have a few questions for you if you tend not to mind.
    Is it only me or does it look like a few of the remarks come
    across like written by brain dead individuals?
    :-P And, if you are posting at other online sites,
    I’d like to follow everything fresh you have to post. Could you make a list of all of all your social sites like your linkedin
    profile, Facebook page or twitter feed?

  4. March 7th, 2014 at 12:12 | #4

    For the reason that the admin of this website is working, no hesitation very quickly it will be renowned, due to
    its quality contents.

  5. August 18th, 2014 at 12:20 | #5

    Thanks for your personal marvelous posting! I seriously enjoyed reading it, you might
    be a great author.I will ensure that I bookmark your blog and will often come back later on. I want to encourage you continue your great
    writing, have a nice evening!

  6. November 21st, 2014 at 02:42 | #6

    While there are currently many commercial real estate property options inside the Philippines, many major corporations often thought
    we would locate their businesses inside biggest business districts within the country.
    Its well-linked infrastructure along with a robust economy made corporate houses setup businesses here.
    All eyes are stored on the White House to find out if Obama’s job plan will receive Republican approval to stimulate
    the position market; however, many Democrats strongly think
    that Obama’s job plan will not provide nearly enough funding to perform need to aid with true economic recovery.

  7. December 20th, 2014 at 12:53 | #7

    There were 8 levels of totally body exercises combined with 8 levels of ab training programs that only took 45 minutes
    per session and I you are only supposed to do these workouts three days a week.
    Hey, when I want to talk like that, I head to the lab.
    This isometric exercise is perfect for stabilizing your core.

  8. July 7th, 2018 at 23:32 | #8


    You probably don’t remember me… Mainly because we’ve never met.

    I want to apologise for sending you this cold email. I know…I shouldn’t have done it.

    But I decided to take a chance, put my big boy pants on and email you anyway because there’s something I had to share.

    My name is Robert and I run the WhatSupp Workout website . I’m writing to you because I’d love to contribute a guest post to your site, eonflex.com.

    I’ve been brainstorming some topics that I think your readers would get a ton of value from:

    – Get fit at home with the top 5 bodyweight exercises
    – How to eat for health and get lean at the same time
    – Forget the gym, here’s how to gain muscle outdoors

    I very much look forward to your response…cursing is expected and welcomed

    Robert Hudson
    WhatSupp workout

  1. No trackbacks yet.