By Fumio Nonaka
26 July 2010
26 July 2010
Some prior experience working with ActionScript 3 is recommended. Familiarity with the Flash authoring environment is also helpful.
This article is the sixth of seven in a series highlighting examples of programming strategies that make it easier than ever before to create rich content in Adobe Flash CS5 Professional. Flash includes new events to enable interactions of multi-touches and gestures with touch panels; these events are implemented in the InteractiveObject class. You can use these new events the same way you work with other events in ActionScript 3. The EventDispatcher.addEventListener() method is used with the event and a listener function is passed as the argument.
The table below lists the new events in the InteractiveObject class that relate to multi-touches and gestures for devices with touch panels. Flash Player 10.1 handles these events by registering listener functions so that they receive notification when an event occurs.
|InteractiveObject class event||Event's constant||Operation triggering the event|
|gesturePan||TransformGestureEvent.GESTURE_PAN||Moving a point of contact|
|gesturePressAndTap||PressAndTapGestureEvent.GESTURE_PRESS_AND_TAP||Creating a point of contact and tapping|
|gestureRotate||TransformGestureEvent.GESTURE_ROTATE||Rotation gesture at a point of contact|
|gestureSwipe||TransformGestureEvent.GESTURE_SWIPE||Swipe gesture at a point of contact|
|gestureTwoFingerTap||GestureEvent.GESTURE_TWO_FINGER_TAP||Pressing two points of contact|
|gestureZoom||TransformGestureEvent.GESTURE_ZOOM||Zoom gesture at a point of contact|
|touchBegin||TouchEvent.TOUCH_BEGIN||Making first contact with a device|
|touchEnd||TouchEvent.TOUCH_END||Removing contact with a device|
|touchMove||TouchEvent.TOUCH_MOVE||Moving the point of contact with a device|
|touchOut||TouchEvent.TOUCH_OUT||Moving the point of contact away from an instance|
|touchOver||TouchEvent.TOUCH_OVER||Moving the point of contact over an instance|
|touchRollOut||TouchEvent.TOUCH_ROLL_OUT||Moving the point of contact away from an instance|
|touchRollOver||TouchEvent.TOUCH_ROLL_OVER||Moving the point of contact over an instance|
|touchTap||TouchEvent.TOUCH_TAP||Lifting the point of contact over the same instance|
Using these new interactive events, you have the ability to make unique and engaging applications for devices that utilize touch screens. To learn more, read the Developer Center article Multitouch and gesture support on the Flash Platform and see the section on InteractiveObject in the ActionScript 3 Reference for the Adobe Flash Platform.
Where to go from here
As you can see from these examples, there are many new possibilities to explore when developing ActionScript 3 projects in Flash Professional CS5. Hopefully the scripts provided in these examples will serve as the starting point as you begin experimenting with the new events and capabilities for delivering rich content with interactivity.
Be sure to check out my other articles in this series:
- Working with TLF Text to control the appearance of text elements
- Manipulating springs of an IK Bone for animations
- Leveraging code snippets and using enhanced code hinting
- Dynamically drawing a vector instance that contains elements
- Displaying the audio waveform captured from a microphone
- Catching errors globally to facilitate troubleshooting
To learn more about developing with ActionScript 3, see the following online resources:
- ActionScript Technology Center
- ActionScript 3.0 Reference for the Adobe Flash Platform
- Adobe ActionScript Cookbook
Also be sure to visit the Flash Developer Center to find more articles and sample files to help you take your Flash projects to the next level.
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License