Jul 26 2011
Adobe Flash – bug or feature – No multitouch gestures on android
After I wrote in one of my last posts about the missing stageVideo on Android devices. Today I want to write about another missing feature.
A very nice “gimmick” of android is the multitouch feature, swipe to left or right to go to another “site”, swipe down to scroll and so on. Adobe write in there actionscript 3.0 api documents, that this feature would be available to all multitouch devices with one exception, the mac os trackpad is not supported:
Note: The Multitouch feature is not supported for SWF files embedded in HTML running on Mac OS.
(source: http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/flash/ui/Multitouch.html)
These days we were working on a flash magazine, which we also optimized for use with tablets. Our client, for whom we has produced successfully an Android AIR magazine demo, asked us if we could integrate swipe gestures for left and right to switch the sites. I said to him, maybe it is possible, I would check it out and call him back. So I adapted our magazine to test the support of multitouch.
The first thing we struggled over is the fact, that Adobe may thought, when developing Flash CS5.5, that there would be no differences between the Flash Player 10.0 and Flash Player 10.1. Very interesting I think
If you are going to try code like this in Flash Player 10.0:
1 2 3 |
import flash.ui.Multitouch; [...] Multitouch.inputMode = MultitouchInputMode.GESTURE |
import flash.ui.Multitouch; [...] Multitouch.inputMode = MultitouchInputMode.GESTURE
Flash will publish your swf without any problems. But if a user with a flash player > 9.x and < 10.1, the flash player will hang without any visible error to the user.
With hang I mean, totally hang, after excuting this lines of code the complete SWF file will stop working. If you try this code with a 10.0 debugger player you get a General Error, and afterwards the code excution stops. So be sure, that this SWF will be only delivered for users with flash palyer 10.1 or greater.
This problem occurs for all multiouch related events and gestures!
A workarround is very simple implemented … simply check with an if-condition which version of the flash player the user has:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
// this function will return true if the flash player version is 10.1 or greater function get multitouchSupported():Boolean { var vAr:Array = Capabilities.version.split(","); if( Number( vAr[0].split(" ")[1] ) < 10 ) { return false; } else if( Number( vAr[0].split(" ")[1] ) > 10 ) { return true; } if( Number( vAr[1] ) > 0 ) { return true; } return false; } |
// this function will return true if the flash player version is 10.1 or greater
function get multitouchSupported():Boolean {
var vAr:Array = Capabilities.version.split(",");
if( Number( vAr[0].split(" ")[1] ) < 10 ) {
return false;
} else if( Number( vAr[0].split(" ")[1] ) > 10 ) {
return true;
}
if( Number( vAr[1] ) > 0 ) {
return true;
}
return false;
}
or check which CPU the device has:
1 2 3 |
if( Capabilities.cpuArchitecture == "arm" ) { // code to excute } |
if( Capabilities.cpuArchitecture == "arm" ) {
// code to excute
}
The second thing I deiscovered for my self, is that it seems, like it is impossible to use multitouch events like the TransformGesture or the general MultiTouch-Actions if your app is running in a browser on an Android device. On my test devices, a Samsung Galxy I9000 (Android 2.3.3) and a Samsung Galaxy Tab 10.1v, there was no multitouch support in the browser. I tested the support with this simple lines of code:
1 2 3 4 5 |
if( Multitouch.supportedGestures == null || Multitouch.supportedGestures.length == 0 ) { trace( "no multitouch support"); } else { trace( "multitouch available"); } |
if( Multitouch.supportedGestures == null || Multitouch.supportedGestures.length == 0 ) {
trace( "no multitouch support");
} else {
trace( "multitouch available");
}
The same code traces “multitouch available” if the code is running as a AIR app on this devices.
I hope, that this will be changed in a feature release of the flash player.
In short:
- Take care, that code like the following is only excuted in a flash payler greater or equal to 10.1, otherwise the SWF will stop working
1 2 3 |
import flash.ui.Multitouch; [...] Multitouch.inputMode = MultitouchInputMode.GESTURE |
import flash.ui.Multitouch; [...] Multitouch.inputMode = MultitouchInputMode.GESTURE
- On Android devices there is at this time no multitouch support available in the browser
