When Flash Player 9 released in June 2006, it introduced the new scripting language, ActionScript 3, which has already taken hold in the Adobe Flex application development community. ActionScript 3 provides not only a significant enhancement in performance, but also a more robust programming model that lends itself to complex Rich Internet Application development.
This is a great time to be a Flash game developer. Right now, there is no better development
tool for small and medium-size games.
Flash CS3 Professional (a.k.a. Flash 9) is fast, powerful, and easy to develop with. The
key to this is ActionScript 3.0, the great new programming language inside this latest
version of Flash.
ActionScript 1.0 and 2.0 were often frustrating for game developers.
từ điển này là cú pháp và cách sử dụng cảu các yếu tố ActionScript trong Macromedia Flash
MX. Từ điển này mô tả cú pháp và cách sử dụng các yếu tố actionscript trong macromedia flash MX. Để sử dụng các thí dụ trong một script, copy đoạn mã mẫu từ actionscript từ điển và dán nó vào trong bảng actions ở chế độ expert mode.
Our look is the result of reader comments, our own experimentation, and feedback from distribution channels. Distinctive covers complement our distinctive approach to technical topics, breathing personality and life into potentially dry subjects. The text font is Linotype Birka; the heading font is Adobe Myriad Pro.
Flash has begun to mature as a product, and ActionScript has begun to mature as a language.
That represents both opportunity and challenge to you. As a mature language,
ActionScript provides a broad spectrum of features and functionality. The possibilities are
limitless: There is great opportunity to build new, innovative, useful, and interesting applications
using Flash and ActionScript. However, with that opportunity comes the challenge of
learning how to use ActionScript effectively.
Procedural Versus Object-Oriented Programming
Procedural Versus Object-Oriented Programming
Much discussion has been made over the pros and cons of procedural and object-oriented programming, and many who are new to ActionScript 3.0 have been led to believe that using OOP is the only way to program in ActionScript 3.0. This is not the case. Object-oriented programming is very powerful, and you’ll probably want to use it when you’re more comfortable with the language.
Core Language fundamentaLs
ActionScript 3.0 is a complete rewrite of the language—so much so that ActionScript 3.0 doesn’t even share the same Flash Player code base as prior versions of ActionScript. But that’s all behind the scenes. The truth is that all versions of ActionScript to date have quite a bit in common.
GraphicS and interaction
Part II represents the largest section of the book, spanning Chapter 3 through Chapter 9. This part covers many significant features that distinguish ActionScript 3.0 from prior versions. It focuses on graphics and interactions and includes the new event model and display list. Chapter 3 is a discussion of properties, events, and methods—the items responsible for manipulating just about anything in Flash.
Managing Object Names, Positions, and Data Types
However, the ActionScript compiler doesn’t know if gotoAndStop() is a legal method of mc’s parent because it doesn’t know the parent’s data type. For example, the parent might be a sprite and a sprite doesn’t have a timeline. As such, you can’t very well go to frame 20 of a sprite.
Removing Event Listeners
Garbage Collection: A Recommended Optional Parameter for Event Listeners
Garbage collection is the method by which Flash Player purges from memory objects that you no longer need. Garbage collection and memory management typically are not topics you need to concern yourself with when just getting started with ActionScript 3.0.
Here is an example structure of the fictional Water class cited in the prior import statement. Note the path—up to, but not including, the class name— in the package declaration. Forgetting to include this will result in a compiler error telling you that the package declaration of the class does not reflect the location of the file.
Reproducing Timeline Tweens with ActionScript
The last thing we want to mention in this chapter is a companion website post about a feature that’s a bit out of the ordinary. As such, we intend it to be an additional resource for your continued study outside this book. In addition to scripting motion solely with code, it’s also possible to rebuild a Flash Professional timeline motion tween using ActionScript.
Loading HTML and CSS
Now we come again to a point where you should stretch the mental muscles and try to take what you’ve learned one step further. The first topic of this section will give you a peak at what we’ll be covering in Chapter 13: loading external assets. You’ll learn how to load and apply external HTML and CSS files. The second topic of this section will give a brief overview of the new Text Layout Framework that brings some advanced typographic support to ActionScript.
Other resources from O’Reilly
ActionScript 3.0 Pocket Reference ActionScript 3.0 Design Patterns Flash 8 Cookbook™ Flash Hacks™ Flash 8 Projects for Learning Animation and Interactivity Flash 8: The Missing Manual Programming Flex 2
oreilly.com is more than a complete catalog of O’Reilly books. You’ll also find links to news, events, articles, weblogs, sample chapters, and code examples. oreillynet.
ActionScript 3.0 Design Patterns takes you step by step through the process, first by explaining how design patterns provide a clear road map for structuring code that actually makes OOP languages easier to learn and use. You then learn about various types of design patterns and construct small abstract examples before trying your hand at building full-fledged working applications outlined in the book. Topics in ActionScript 3.0 Design Patterns include: