The accelerometer provides access to data that represents the device's location or movement along a three-dimensional axis. When motion is detected, it is returned as data, which can be accessed by ActionScript.
This recipe will show you how to take advantage of the accelerometer found in iOS devices.
An FLA has been provided as a starting point.
Open chapter9\recipe4\recipe.fla
from the book's accompanying code bundle into Flash Professional.
You will find five dynamic text fields positioned on the stage. Below them is a movie clip with an instance name of arrow
. We will populate each text field with data retrieved from the device's accelerometer and rotate the movie clip to reflect physical changes in the device's orientation.
Also notice the stage's dimensions are set to 480x320. For this recipe, landscape orientation will be used.