03 September 2009

Important AS command on touch devices

I was testing my last game (coming this month), when I suddenly found a strange behavior : pressing the OK key, I come back to the title screen...
It's not a crash since I didn't exit the game.
I tried to make this bug again without success...until I realized I was on a touch device : the N97.
I finally found the reason : OK key valids (similar to a press command) the current selected movieclip.
I didn't notice it before since I set _focusrect to false.

So, the AS commands needed to handle a touch AND a non touch game are

- focusRect = false to avoid the ugly rect around movieClip
- if(System.capabilities.hasStylus || System.capabilities.hasMouse) to handle touch-only stuff, like myfakesoftkey.onRelease =
- myfakesoftkey.trackAsMenu = true to handle touch move while pressing a touchbouton
- myfakesoftkey.tabEnabled = false to avoid movieclip to be 'selected' while using right and left key (and I assume you use them a lot on a game!)
- fscommand2("DisableKeypadCompatibilityMode"); to hide the ugly fake keyboard on Nokia touch devices

No comments: