- Introduction
- 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 Multitouch in an App
By default, Flash assumes that you are using a mouse to touch the screen. This actually works OK for many iPhone Apps and allows you to take the same code you have developed for other Flash movies and move it into your iPhone projects. That’s OK, but what about those cool iPhone gestures (New!) you see people using to swipe content? Flash can do that, too.
For the iPhone, Flash supports the following Multitouch gestures:
- TransformGestureEvent.GESTURE_PAN
- TransformGestureEvent.GESTURE_ROTATE
- TransformGestureEvent.GESTURE_SWIPE
- TransformGestureEvent.GESTURE_ZOOM
Each gesture is used as an interactive event in a Listener. This means that you can take your knowledge of Listeners and quickly apply it to iPhone Apps. The following example shows you how to add a swipe gesture that will trigger a movie clip to fade onto the screen.
Use the Multitouch Class
- Create a new iPhone App, apply the appropriate development profiles and certificates, and then save the file with the name iPhoneMultitouch.fla.
- Draw a rectangle on the Stage, and then convert the rectangle into a Movie Clip with the name myMovie.
- Open the Actions panel.
- Add code to import the class libraries:
import flash.ui.Multitouch; import flash.ui.MultitouchInputMode;
- Set the default Alpha value for the Movie Clip to 0:
myMovie.alpha = 0;
- Add a listener and function that enable the Movie Clip to fade onto the screen (see illustration).
- Publish and package your file into an iPhone App and test it on your iPhone.