Home > Articles > Web Development > Dreamweaver & Flash

  • Print
  • + Share This
This chapter is from the book

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

  • orange-circle-1.jpg Create a new iPhone App, apply the appropriate development profiles and certificates, and then save the file with the name iPhoneMultitouch.fla.
  • orange-circle-2.jpg Draw a rectangle on the Stage, and then convert the rectangle into a Movie Clip with the name myMovie.
  • orange-circle-3.jpg Open the Actions panel.
  • orange-circle-4.jpg Add code to import the class libraries:
    import flash.ui.Multitouch;
    import flash.ui.MultitouchInputMode;
  • orange-circle-5.jpg Set the default Alpha value for the Movie Clip to 0:
    myMovie.alpha = 0;
  • orange-circle-6.jpg Add a listener and function that enable the Movie Clip to fade onto the screen (see illustration).
  • orange-circle-7.jpg Publish and package your file into an iPhone App and test it on your iPhone.
  • + Share This
  • 🔖 Save To Your Account