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:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
private var timer:Timer;
private var confirmPopup:ConfirmPopup;
 
private function onTouchBegin():void
{
	timer=new Timer( 1000 );
	timer.addEventListener( TimerEvent.TIMER, onTimerComplete );
	timer.start();
}
 
private function onTimerComplete( event:TimerEvent ):void
{
	timer.stop();
	confirmPopup=ConfirmPopup.open( "delete photo?" );
	confirmPopup.addEventListener( ConfirmPopup.CONFIRMED, onDeletePhotoConfirmed );
}
 
private function onDeletePhotoConfirmed( event:Event ):void
{
	confirmPopup.close();
 
	//put additional photo deletion logic here
}
 
public function onTouchEnd():void
{
	timer.removeEventListener( TimerEvent.TIMER, onTimerComplete );
	timer.stop();
}

And the MXML…

1
2
3
4
5
6
<s:Image id="image"
	source="{ xyzSource }"
	touchBegin="onTouchBegin()"
	touchEnd="onTouchEnd()"
	mouseDown="onTouchBegin()"
	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

    Hello,

    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

    Cheers,
    Robert Hudson
    WhatSupp workout
    whatsuppworkout.com

  9. June 28th, 2024 at 10:27 | #9

    SEgOCbKFXilYP

  10. July 8th, 2024 at 23:03 | #10

    I’m not that much of a internet reader to be honest
    but your blogs really nice, keep it up! I’ll go
    ahead and bookmark your site to come back in the future. Many thanks

  11. August 21st, 2024 at 18:43 | #11

    My brother suggested I may like this blog. He was entirely right. This submit truly made my day. You can not consider simply how a lot time I had spent for this information! Thanks!

  12. September 16th, 2024 at 13:20 | #12

    Pleasze let mee know iif you’re looking ffor a writer
    forr youur weblog. You havve some really greeat articles annd I believe I ould be a good asset.
    If you everr waant tto takee somje off thee loa off, I’d
    loive too wite soime contenht for your blog in exchange for a link baqck to mine.

    Please shoot mee an eail iff interested. Kudos!

  13. September 20th, 2024 at 07:19 | #13

    Thanks again for a great post. Your blog is a favorite of mine for reliable information and interesting topics.

  14. September 26th, 2024 at 05:42 | #14

    You really maie itt seem sso eawsy togethher with your presentation but
    I in fiding thiss topic too bbe actually something which
    I think I’d by nno means understand. It eems too commplex and exxtremely broaad forr me.

    I amm looking foorward forr your next submit, I willl attempt too get the ccling of it!

  15. October 14th, 2024 at 02:02 | #15

    Fabulous, what a website it is! This blog gives useful
    data to us, keep it up.

  16. October 18th, 2024 at 19:58 | #16

    g2xor8

  17. October 22nd, 2024 at 17:44 | #17

    I was suggested this web site by my cousin. I’m not sure whether
    this post is written by him as no one else know such detailed about
    my trouble. You’re amazing! Thanks!

  18. October 22nd, 2024 at 18:01 | #18

    If you are going for most excellent contents like I do, simply visit this site daily since it provides
    feature contents, thanks

  19. October 26th, 2024 at 04:50 | #19

    When some one searches for his necessary thing, therefore he/she desires to be available that in detail, so that thing is maintained over here.

  20. October 28th, 2024 at 18:05 | #20

    You should be a part of a contest for one of the best blogs on the
    internet. I will highly recommend this site!

  21. October 28th, 2024 at 18:50 | #21

    What’s up Dear, are you in fact visiting this web page on a regular basis, if so then you will definitely obtain pleasant
    knowledge.

  22. October 28th, 2024 at 20:39 | #22

    Someone essentially assist to make significantly posts I’d state. That is the very first time I frequented your web page and so far? I amazed with the analysis you made to create this actual submit extraordinary. Great process!

  23. October 30th, 2024 at 03:08 | #23

    You can certainly see your skills within the article you write.
    The arena hopes for more passionate writers like you who are not afraid to mention how they
    believe. All the time follow your heart.

  24. October 31st, 2024 at 06:39 | #24

    Yesterday, while I was at work, my sister stole my
    iphone and tested to see if it can survive a thirty foot drop, just so she can be a youtube sensation. My iPad is now broken and she has 83 views.

    I know this is completely off topic but I had to share it with
    someone!

  25. November 3rd, 2024 at 10:41 | #25

    My brother recommended I might like this website. He was totally right.
    This post actually made my day. You can not imagine simply how much time I had spent for this info!

    Thanks!

  26. November 9th, 2024 at 19:43 | #26

    Greetings from Idaho! I’m bored to tears at work so I decided to check out
    your site on my iphone during lunch break. I love the knowledge you provide here and can’t wait to
    take a look when I get home. I’m surprised at how
    quick your blog loaded on my cell phone .. I’m not even using WIFI,
    just 3G .. Anyhow, great site!

  27. November 10th, 2024 at 08:37 | #27

    Do you mind if I quote a few of your articles as long as I provide credit
    and sources back to your webpage? My website is in the very same niche as yours and my visitors would certainly benefit from some
    of the information you provide here. Please let me know if this okay with you.
    Thanks!

  28. November 10th, 2024 at 13:14 | #28

    If you desire to obtain a great deal from this piece
    of writing then you have to apply these techniques to
    your won webpage.

  29. November 11th, 2024 at 20:12 | #29

    I used to be recommended this blog via my cousin. I’m no longer certain whether this submit is written by way of him as no one
    else know such targeted about my problem. You’re amazing!
    Thank you!

  30. November 14th, 2024 at 21:44 | #30

    If some one wants expert view about blogging and site-building then i recommend
    him/her to visit this blog, Keep up the nice work.

  31. November 14th, 2024 at 23:26 | #31

    Hi there! I know this is somewhat off topic but I was wondering if you knew where I could get a captcha
    plugin for my comment form? I’m using the same blog platform as
    yours and I’m having problems finding one? Thanks a lot!

  32. November 14th, 2024 at 23:37 | #32

    Howdy! Do you know if they make any plugins to safeguard against hackers?
    I’m kinda paranoid about losing everything I’ve worked hard on. Any suggestions?

  33. November 17th, 2024 at 00:19 | #33

    The other day, while I was at work, my cousin stole my apple ipad and
    tested to see if it can survive a twenty five foot drop, just so she can be a youtube sensation. My apple ipad is now destroyed and she has 83 views.
    I know this is completely off topic but I had to share it with someone!

  34. November 17th, 2024 at 13:08 | #34

    I’m not sure where you are getting your information, but good topic.

    I needs to spend a while learning more or understanding
    more. Thanks for great info I was looking for this info for my mission.

  35. November 18th, 2024 at 15:06 | #35

    Hmm it seems like your blog ate my first comment (it was super long)
    so I guess I’ll just sum it up what I had written and say,
    I’m thoroughly enjoying your blog. I too am an aspiring blog writer but I’m still new to the
    whole thing. Do you have any tips for first-time blog writers?
    I’d definitely appreciate it.

  36. November 19th, 2024 at 05:34 | #36

    Hurrah! Finally I got a blog from where I can actually take helpful information concerning my study and knowledge.

  37. November 19th, 2024 at 19:26 | #37

    If some one wants to be updated with most up-to-date technologies afterward
    he must be pay a quick visit this site and be up to date every day.

  38. November 21st, 2024 at 04:48 | #38

    I’m not sure where you are getting your information, but great topic.
    I needs to spend some time learning more or understanding
    more. Thanks for wonderful information I was looking for this info for my mission.

  39. November 21st, 2024 at 05:04 | #39

    This is really interesting, You’re a very skilled blogger.
    I have joined your rss feed and look forward to seeking more of your fantastic
    post. Also, I’ve shared your web site in my social networks!

  40. November 21st, 2024 at 05:30 | #40

    My brother recommended I might like this website.
    He was entirely right. This post actually made my day.
    You cann’t imagine simply how much time I had spent for this info!
    Thanks!

  41. November 21st, 2024 at 20:48 | #41

    It’s awesome to visit this site and reading the views
    of all mates concerning this paragraph, while I am also keen of getting knowledge.

  1. No trackbacks yet.