Namespaces

Variants
Actions

Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Revision as of 06:06, 14 May 2013 by hamishwillee (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Archived:Detecting Long Press in Flash Lite

From Wiki
Jump to: navigation, search

Archived.pngArchived: This article is archived because it is not considered relevant for third-party developers creating commercial solutions today. If you think this article is still relevant, let us know by adding the template {{ReviewForRemovalFromArchive|user=~~~~|write your reason here}}.

We do not recommend Flash Lite development on current Nokia devices, and all Flash Lite articles on this wiki have been archived. Flash Lite has been removed from all Nokia Asha and recent Series 40 devices and has limited support on Symbian. Specific information for Nokia Belle is available in Flash Lite on Nokia Browser for Symbian. Specific information for OLD Series 40 and Symbian devices is available in the Flash Lite Developers Library.

Article Metadata
Code Example
Source file: Media:LongPress.zip
Article
Created: manikantan (17 Apr 2010)
Last edited: hamishwillee (14 May 2013)


Contents

Introduction

Mobile phones have started replacing desktop computers. To facilitate uniform and good control and experience, many desktop user interface and interaction components have been ported to mobile phones. This is because, usability and experience of these ( WIMP - Windows, Icons, Menus, Pointing Device) have been extremely tested and have been proven successful and intuitive. Today's phones have touch-based interaction that is analogous to mouse control on the desktop. But careful analysis shows that not all capabilities of the mouse have been ported to the phone. The mouse provide 2 Clicks ( right and left), but with the finger based touch only one of them is possible. However this can be extended by differentiating a touch into Long Press and Short Press.

This articles shows how LongPress gestures can be detected in Flash Lite. This was tested on the touch-based phone Nokia 5800 XPressMusic. The SWF is published under Flash Lite 2.0

Long Press and its associated issues

Long presses have been long used in Nokia's keypad phones in the messaging context. Similarly, long press was also in the Contacts book of Nokia 5800 XpressMusic. Long Press in any contact results in pop-up of a menu. In most generic way, it is logical to associate the long press with a Menu. It is simply because most Right Clicks on the desktop computers give a menu, be it on the computer's desktop or on a browser. It is most likely to result in a menu.

The design of such components (that support Long and short Press) has to be very carefully designed. The most frequently used/ open of the item should be associated with the ShortPress. And least number of frequently used options from the menu should be on the LongPress menu. Inspired from the contacts book in 5800, short press on a contact results in opening the contact and the longPress presents a short menu. Also once the click exceeds the limit of a shortPress, there has to be an indication of the same. This indication is through a circle of increasing radius.

Similar interaction paradigm has been replicated in this Flash Lite code below.

Implementation

As it can be seen from the screenshot, there is button which can accept both shortPress and longPress. If the user makes a shortPress, then an increment in number of shortPress (shown in the textfield), is made. Also a circle of increasing radius is shown once the time limit of shortPress expires.

Ss Longpress.jpg

f1 =0;  // f1 is a flag to test the press of bt
bt.onPress = function() {
clickTime = new Date();
f1 =1;
}
lp_cnt=0; sp_cnt =0;
bt.onRelease = function() {
relTime = new Date();
elapsed = relTime.getTime() - clickTime.getTime();
trace( "ELAPSED" + elapsed);
if( elapsed > 300) // shortPress threshold = 300 milliseconds
{ lp_cnt++;lp.text = lp_cnt; }
else { sp_cnt++; sp.text = sp_cnt;}
removeMovieClip(c);
lpcnt=0;
f1=0;
}
lpcnt =0;
function callback() {
if(f1 ==1 and lpcnt>6 ){
// It is 6 because 50*6 = 300(threshold)
attachMovie("circ","c",this.getNextHighestDepth());
//attaching the CIRC movieclip to mouse position
c._x = _xmouse;
c._y = _ymouse;
lpcnt++;return;
}
if(f1>0) lpcnt++;
}
var intervalID:Number = setInterval(callback, 50);

Generating a menu to emanate a menu is simple in Flash and is not the focus of this article.


Download

Media:LongPress.zip


Conclusion

This code example presents the idea of longPress, its opportunities in limited interaction environments like the mobile phones. A code example in Flash Lite that replicates this interaction is also included.

This page was last modified on 14 May 2013, at 06:06.
41 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.

 

Thank you!

We appreciate your feedback.

×