23 June 2008
ActionScript 3 represents a significant change for many Flash users, and a steeper learning curve for the uninitiated. To make learning easy for you and to demonstrate how you can use the Flash language for practical, everyday projects, Rich Shupe and Zevan Rosser share their knowledge in Learning ActionScript 3.
If you are new to the language, follow this hands-on book to learn how ActionScript and Flash work together. You'll get a clear look into essential topics such as logic, event handling, displaying content, classes, and migrating legacy projects to ActionScript 3. The first few chapters expand your skill set by taking you through a variety of scripting scenarios and focusing on clear, concise examples in the Flash Timeline that do not draw heavily on prior knowledge of object-oriented programming (OOP). As the chapters progress, the book gradually introduces more and more OOP techniques, allowing you to choose which scripting approach you prefer.
If you are already comfortable with OOP, refer to the companion website for all the exercises in the book, as well as short quizzes to make sure you're up to speed with key concepts. Topics in Learning ActionScript 3 also include:
Learning ActionScript 3 © 2008 Rich Shupe. Reproduced by permission of O'Reilly Media Inc. All rights reserved.
Chapter 1 covers basic information on ActionScript 3, the Flash platform, procedural versus OOP, the Document class, and legacy code compatibility. It provides a brief overview of ActionScript development, giving you some insight into its use—particularly related to Flash Player and how it handles different versions of ActionScript. It tells you how this version of ActionScript is handled separately from its previous versions at runtime, yet explains how the fundamentals of the language are the same throughout.
The chapter also provides answers to questions like why moving to ActionScript 3 doesn't require you to become an expert at OOP and how Flash CS3 offers a simpler entrance to an OOP application by way of the Document class. Finally, the section on legacy code compatibility briefly introduces the issues involved in developing projects on ActionScript 3 that support older code.
Chapter 4 explores the properties of the newly introduced display list in ActionScript 3. One of the most dramatic changes for those designers accustomed to prior versions of ActionScript is the way in which visual elements are added to an application at runtime. ActionScript 3 brings with it an entirely new way of handling visual assets. The display list is a hierarchical list of all visual elements in your file. This chapter introduces you to different objects that can be part of the display list, and helps you grasp the simple difference between display objects and display object containers. It also provides information on manipulating existing members of the display list, adding and removing objects from the list, and changing the hierarchy of assets. The concluding section shows you how to dynamically generate a very simple navigation bar.
Chapter 7 takes an in-depth look at programming motion in ActionScript 3. Because motion can cover a large number of concepts, the book focuses on only a few—offering simplified simulations in each area and presenting approaches that are simple enough to integrate into your projects with ease.
You begin with simplified movement before learning how to determine the distance between two objects, and then how to animate objects in a circular path and point objects at a specific location. You also learn how to add realism to animations by simulating friction, elasticity, and gravity.
In the section on programmatic tweening, you will read about the Tween class and its occasional partner, the Easing package. The new Animator class in ActionScript 3 can read the XML that you export from timeline tweens and recreate that animation with ActionScript. You will create a simple player for displaying such an animation.
The chapter ends with an applied example of creating a simple particle, covering much of what has been discussed in the chapter.