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:
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
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!
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?
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?
For the reason that the admin of this website is working, no hesitation very quickly it will be renowned, due to
its quality contents.
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!
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.
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.
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
SEgOCbKFXilYP
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
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!
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!
Thanks again for a great post. Your blog is a favorite of mine for reliable information and interesting topics.
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!