The availability of an on-board GPS unit makes it possible to determine your speed and heading. In this recipe, we will write a simple app that uses the
Geolocation
class to obtain and use this information. In addition, we will add compass functionality by utilizing the user's current heading.
You will need a GPS-enabled iOS device. The iPhone has featured an on-board GPS unit since the release of the 3G. GPS hardware can also be found in all cellular network-enabled iPads.
From Flash Professional, open chapter9\recipe2\recipe.fla
from the book's accompanying code bundle.
Sitting on the stage are three dynamic text fields. The first two (speed1Field
and speed2Field
) will be used to display the current speed in meters per second and miles per hour respectively. We will write the device's current heading into the third—headingField
.
Also, a movie clip named compass
has been positioned near the bottom of the stage and represents a compass with north...