- Becoming an Apple Certified Developer
- Registering an iPhone and Other Apple Testing Devices
- Creating App IDs
- Creating a Developers Provisioning Profiles
- Creating and Publishing an iPhone App
- Controlling the Accelerometer
- Saving Images to the Camera Roll
- Understanding the Limits of Flash
- Identifying Devices to Deploy an Ad Hoc App
- Creating an Ad Hoc Distribution Profile
- Packaging an Ad Hoc App
- Packaging an App for the iTunes App Store
- Using iTunes Connect to Publish an App
- Using Screen Orientation in an App
- Using Geolocation in an App
- Using Multitouch in an App
Using Screen Orientation in an App
The iPhone has one characteristic that you will not see on a desktop or laptop computer: it can be easily rotated. Determining orientation can allow you to add interesting effects to your iPhone Apps (New!). For instance, the default Stocks tool on your iPhone will show you the numbers of a particular stock when you hold your phone in portrait; switch the phone to landscape and the content changes to a line chart illustrating how the stock is performing. This trick is accomplished through the iPhone being able to detect the orientation of the device. The iPhone can detect Orientation in four distinct directions:
- Default – Portrait
- Rotation Left – Landscape
- Rotation Right – Landscape
- Upside Down – Portrait, upside down
ActionScript contains a special class called the Orientation Class, which allows you to control content on the screen depending on the orientation of the device.
Use the Screen Orientation Class
- Create a new iPhone App, apply the appropriate provisioning profiles, and then save the file with the name iPhoneOrientation.fla.
- Add a dynamic text box to the Stage with the name myTxt, and then apply the _Sans font.
- Open the Actions Panel.
- Add a listener and function that changes the content of the text box based on the orientation of the device (see illustration).
- Publish and package your file into an iPhone App and test it on your iPhone. Rotate your iPhone to see the text change on
In addition to using ActionScript to control the orientation of your phone, you can also have the whole movie auto-orientate as a default setting in your iPhone Settings screen. On the whole, however, you have much tighter control over your content is you use ActionScript to control the orientation of specific movies, sprites and objects over the auto-orientation Boolean setting.