Essential ActionScript 2.0
|
| Price: |
15 new or used available from £2.63
Average customer review:Product Description
In September 2003, Macromedia released Flash MX 2004, and with it, ActionScript 2.0, a dramatically improved version of Flash's programming language. ActionScript 2.0 introduces a formal object-oriented programming syntax and methodology for creating Flash applications. From a developer's perspective, the new OOP-based techniques in ActionScript 2.0 make applications more natural to plan and conceptualize, more stable, more reusable across projects, easier to maintain, change, and expand upon, and much more. In short, they enhance the entire development process. In Essential ActionScript 2.0, bestselling author Colin Moock--one of the most universally respected developers in the Flash community--covers everything you'll need to know about the new ActionScript language and its methodologies for producing movies, animation, and applications on the web. Moock guides readers through this important new territory with his trademark easy-to-understand style and expertise. Moock's goal throughout the book is not just to get you to use object-oriented programming in your daily Flash work: he wants you to reap the benefits of OOP; he wants you to understand ActionScript 2.0 completely. And without question, Moock is the author who can make this happen. Essential ActionScript 2.0 begins with a tour of the language, including the fundamentals of object-oriented concepts, syntax, and usage. Those who are new to OOP will learn the basics and how to apply their understanding. Those who are familiar with OOP will leverage their prior experience to learn about Flash-based OOP. The next part of the book shows how to structure entire applications with ActionScript 2.0, teaching you best practices and techniques to build scalable, extensible, stable apps. Next, you'll explore a variety of approaches to various programming situations by applying object-oriented programming strategies, known as design patterns, to Flash. Experienced Flash developers and programmers coming from other languages will enjoy the sheer depth of Moocks's coverage and expertise in Essential ActionScript 2.0. Novice programmers will appreciate the frequent, low-jargon explanations that are often glossed over by advanced programming books. As usual, Moock guarantees quality and accuracy by working closely with Macromedia Flash engineers, including Rebecca Sun, lead developer of ActionScript 2.0. Whether you're ready to make the move to ActionScript 2.0 now or simply assessing it for the future, you'll find everything you need to know within this book. Essential ActionScript 2.0 is the one book every ActionScript coder must own.
Product Details
- Amazon Sales Rank: #359985 in Books
- Published on: 2004-06-16
- Original language: English
- Number of items: 1
- Binding: Paperback
- 502 pages
Editorial Reviews
Computer Shopper, March
"An intelligent view of ActionScript"
About the Author
Colin Moock is an independent web guru with a passion for networked creativity and expression. He has been researching, designing, and developing for the Web since 1995. Colin served as webmaster for SoftQuad, Inc. (makers of HoTMetaL PRO) until 1997, and then as web evangelist for ICE (one of Canada's leading interactive agencies) until 2001. He has created interactive content for Sony, Levi's, Nortel, Air Canada, Procter & Gamble, and Hewlett-Packard. Colin now divides his time between writing, speaking at conferences, and researching emerging web technology. His award-winning Flash work and his renowned support site for Flash developers (http://www.moock.org) have made him a well-known personality in the Flash developer community. He is a contributor to macromedia.com's Flash developer center, a tutorialist in the Flash MX Bible (2002, Wiley Publishing Inc.), and regularly appears in industry magazines such as cre@te! online. Colin's latest personal undertaking is Unity (http://www.moock.org/unity/), a Flash socket server for multi-user content.
Excerpted from Essential ActionScript 2.0 by Colin Moock. Copyright © 2004. Reprinted by permission. All rights reserved.
CHAPTER 2 - Object-Oriented ActionScript
Ironically, Flash users who are new to object-oriented programming (OOP) are often familiar with many object-oriented concepts without knowing their formal names. This chapter demystifies some of the terminology and brings newer programmers up to speed on key OOP concepts. It also serves as a high-level overview of OOP in ActionScript for experienced programmers who are making their first foray into Flash development.
Procedural Programming and Object-Oriented Programming
Traditional programming consists of various instructions grouped into procedures. Procedures perform a specific task without any knowledge of or concern for the larger program. For example, a procedure might perform a calculation and return the result. In a procedural-style Flash program, repeated tasks are stored in functions and data is stored in variables. The program runs by executing functions and changing variable values, typically for the purpose of handling input and generating output. Procedural programming is sensible for certain applications; however, as applications become larger or more complex and the interactions between procedures (and the programmers who use them) become more numerous, procedural programs can become unwieldy. They can be hard to maintain, hard to debug, and hard to upgrade.
Object-oriented programming (OOP) is a different approach to programming, intended to solve some of the development and maintenance problems commonly associated with large procedural programs. OOP is designed to make complex applications more manageable by breaking them down into self-contained, interacting modules. OOP lets us translate abstract concepts and tangible real-world things into corresponding parts of a program (the "objects" of OOP). It’s also designed to let an application create and manage more than one of something, as is often required by user interfaces. For example, we might need 20 cars in a simulation, 2 players in a game, or 4 checkboxes in a fill-in form.
Properly applied, OOP adds a level of conceptual organization to a program. It groups related functions and variables together into separate classes, each of which is a self-contained part of the program with its own responsibilities. Classes are used to create individual objects that execute functions and set variables on one another, producing the program’s behavior. Organizing the code into classes makes it easier to create a program that maps well to real-world problems with real-world components. Parts II and III of this book cover some of the common situations you’ll encounter in ActionScript, and show how to apply OOP solutions to them. But before we explore applied situations, let’s briefly consider the basic concepts of OOP.
Key Object-Oriented Programming Concepts
An object is a self-contained software module that contains related functions (called its methods) and variables (called its properties). Individual objects are created from classes, which provide the blueprint for an object’s methods and properties. That is, a class is the template from which an object is made. Classes can represent theoretical concepts, such as a timer, or physical entities in a program, such as a pull-down menu or a spaceship. A single class can be used to generate any number of objects, each with the same general structure, somewhat as a single recipe can be used to bake any number of muffins. For example, an OOP space fighting game might have 20 individual SpaceShip objects on screen at one time, all created from a single SpaceShip class. Similarly, the game might have one 2dVector class that represents a mathematical vector but thousands of 2dVector objects in the game.
The term instance is often used as a synonym for object. For example, the phrases "Make a new SpaceShip instance" and "Make a new SpaceShip object" mean the same thing. Creating a new object from a class is sometimes called instantiation.
To build an object-oriented program, we:
1. Create one or more classes.
2. Make (i.e., instantiate) objects from those classes.
3. Tell the objects what to do.
What the objects do determines the behavior of the program.
In addition to using the classes we create, a program can use any of the classes built into the Flash Player. For example, a program can use the built-in Sound class to create Sound objects. An individual Sound object represents and controls a single sound or a group of sounds. Its setVolume( ) method can raise or lower the volume of a sound. Its loadSound( ) method can retrieve and play an MP3 sound file. And its duration property can tell us the length of the loaded sound, in milliseconds. Together, the built-in classes and our custom classes form the basic building blocks of all OOP applications in Flash.
Class Syntax
Let’s jump right into a tangible example. Earlier, I suggested that a space fighting game would have a SpaceShip class. The ActionScript that defines the class might look like the source code shown in Example 2-1 (don’t worry if much of this code is new to you; we’ll study it in detail in the coming chapters).
Example 2-1. The SpaceShip class
class SpaceShip {
// This is a public property named speed.
public var speed:Number;
// This is a private property named damage.
private var damage:Number;
// This is a constructor function, which initializes
// each SpaceShip instance.
public function SpaceShip ( ) {
speed = 100;
damage = 0;
}
// This is a public method named fireMissile( ).
public function fireMissile ( ):Void {
// Code that fires a missile goes here.
}
// This is a public method named thrust( ).
public function thrust ( ):Void {
// Code that propels the ship goes here.
}
}
Notice how the SpaceShip class groups related aspects of the program neatly together (as do all classes). Variables (properties), such as speed and damage, related to spaceships are grouped with functions (methods) used to move a spaceship and fire itsweapons. Other aspects of the program, such as keeping score and drawing the background graphics can be kept separate, in their own classes (not shown in this example).
Customer Reviews
The essential guide for wannabe OOPs moving from AS1 to AS2.
If you, like me, got very good at designing prototypes and objects for Flash MX and want to know how to migrate to AS 2.0, or if you simply want to learn how to build proper object oriented classes, then this is an extremely well written book which has an in-depth explanation of all that you need.
It is not a beginners' guide, but for those who already understand ActionScript, it is the way to go.
Write real applications with Actionscript
Actionscript 2 has effectively promoted AS1 to be a 'real' programming language for big, complex Flash applications that would be difficult to do with AS1. This book covers all you need to create robust AS2 OOP classes and full applications in a style that Java & C++ programmers will be familiar with. Moock's writing style is just so good at explaining fiddly subjects in pleasant bite-sized chunks. The examples are excellent, taking you step by step through the creation and structure of full AS2 applications. The coverage of how to use and create your own flash components is also excellent. An essential purchase for the serious Flash developer and a perfect partner to 'Actionscript: The Definitive Guide'
OOP and Actionscript 2.0
First of all, Colin makes this book an extension for his exploration of Flash Programming after his book ActionScript for Flash MX The Definitive Guide, which explain the ActionScript Fundamentals but Essential ActionScript 2.0 focuses almost exclusively on the Object-Oriented Programming aspects (in) ActionScript.
The book is divided to three main sections:-
1. Part I: The ActionsScript 2.0 language: discusses the theory of OOP in general, and itsimplementation in Action Script in particular. Colin really is great in clarifying the concepts in a simple manner with examples.
2. Part II: Application Development: discusses the concepts for the practical application, which is covered in the first section with examples describe the process of designing and deploying and object-oriented application.
3. Part II: Design Pattern Examples: Colin means by that how to apply OOP strategies to a many approaches to various programming situations in Macromedia Flash.
· New to OOP Programmers will learn the basics and how to apply it.
· Familiar with OOP Programmers will gain experience with Flash-based OOP.
· Experienced Flash developers and programmers coming from other languages will enjoy the deep coverage and expertise in Essential ActionScript 2.0.
Finally and in sum, this book reviews the Object-Oriented definite structures in ActionScript 2.0 realistically to get benefit from applying these concepts through the abstract theory and the practical tips.





