Detecting a shake
A common use of the accelerometer is to detect a shake and this has become a popular method of interaction in games and applications. For example, many of the apps that come with iOS allow the user to perform an undo by shaking the device.
This recipe will show you how to determine if the user is shaking their device by examining the data coming from the accelerometer.
Getting ready
From the book's accompanying code bundle, open chapter9\recipe5\recipe.fla
into Flash Professional.
You will find a movie clip named shake
sitting in the center of the stage. Its timeline consists of two key-frames.
We will write some ActionScript that will move the clip in response to changes along the device's three axes. When the motion is pronounced, ...
Get Flash iOS Apps Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.