PDF Archive

Easily share your PDF documents with your contacts, on the Web and Social Networks.

Share a file Manage my documents Convert Recover PDF Search Help Contact



OReilly.Essential.ActionScript.3.0.Jun.2007 .pdf



Original filename: OReilly.Essential.ActionScript.3.0.Jun.2007.pdf

This PDF 1.6 document has been generated by FrameMaker 5.5.6. / Acrobat Distiller 4.05 for Sparc Solaris, and has been sent on pdf-archive.com on 26/10/2014 at 04:06, from IP address 98.182.x.x. The current document download page has been viewed 3132 times.
File size: 4.9 MB (947 pages).
Privacy: public file




Download original PDF file









Document preview


Essential ActionScript 3.0

Other resources from O’Reilly
Related titles

oreilly.com

ActionScript 3.0 Design
Patterns
Dynamic HTML: The
Definitive Reference
Ajax on Java

Ajax on Rails
Learning JavaScript
Programming Atlas
Head Rush Ajax
Rails Cookbook

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.com is the essential portal for developers interested in
open and emerging technologies, including new platforms, programming languages, and operating systems.

Conferences

O’Reilly brings diverse innovators together to nurture the ideas
that spark revolutionary industries. We specialize in documenting the latest tools and systems, translating the innovator’s
knowledge into useful skills for those in the trenches. Visit conferences.oreilly.com for our upcoming events.
Safari Bookshelf (safari.oreilly.com) is the premier online reference library for programmers and IT professionals. Conduct
searches across more than 1,000 books. Subscribers can zero in
on answers to time-critical questions in a matter of seconds.
Read the books on your Bookshelf from cover to cover or simply flip to the page you need. Try it today with a free trial.

Essential ActionScript 3.0

Colin Moock

Beijing • Cambridge • Farnham • Köln • Paris • Sebastopol • Taipei • Tokyo

Essential ActionScript 3.0
by Colin Moock
Copyright © 2007 O’Reilly Media, Inc. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions
are also available for most titles (safari.oreilly.com). For more information, contact our
corporate/institutional sales department: (800) 998-9938 or corporate@oreilly.com.

Editor: Steve Weiss
Developmental Editor: Robyn G. Thomas
Production Editor: Philip Dangler
Proofreader: Mary Anne Weeks Mayo

Indexer: John Bickelhaupt
Cover Designer: Karen Montgomery
Interior Designer: David Futato
Illustrators: Robert Romano and Jessamyn Read

Printing History:
August 2007:

First Edition.

Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of
O’Reilly Media, Inc. Essential ActionScript 3.0, the image of a coral snake, and related trade dress are
trademarks of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as
trademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a
trademark claim, the designations have been printed in caps or initial caps.
While every precaution has been taken in the preparation of this book, the publisher and author assume
no responsibility for errors or omissions, or for damages resulting from the use of the information
contained herein.

This book uses RepKover™, a durable and flexible lay-flat binding.
ISBN-10: 0-596-52694-6
ISBN-13: 978-0-596-52694-8
[M]

Table of Contents

Foreword . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xix

Part I.

ActionScript from the Ground Up

1. Core Concepts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Tools for Writing ActionScript Code
Flash Client Runtime Environments
Compilation
Quick Review
Classes and Objects
Creating a Program
Packages
Defining a Class
Virtual Zoo Review
Constructor Methods
Creating Objects
Variables and Values
Constructor Parameters and Arguments
Expressions
Assigning One Variable’s Value to Another
An Instance Variable for Our Pet
Instance Methods
Members and Properties
Virtual Zoo Review
Break Time!

3
4
5
6
6
8
9
11
13
14
16
19
24
26
28
30
31
42
42
43

v

2. Conditionals and Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
Conditionals
Loops
Boolean Logic
Back to Classes and Objects

44
50
58
62

3. Instance Methods Revisited . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 63
Omitting the this Keyword
Bound Methods
Using Methods to Examine and Modify an Object’s State
Get and Set Methods
Handling an Unknown Number of Parameters
Up Next: Class-Level Information and Behavior

64
66
68
72
75
76

4. Static Variables and Static Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
Static Variables
Constants
Static Methods
Class Objects
C++ and Java Terminology Comparison
On to Functions

77
80
82
85
86
86

5. Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
Package-Level Functions
Nested Functions
Source-File-Level Functions
Accessing Definitions from Within a Function
Functions as Values
Function Literal Syntax
Recursive Functions
Using Functions in the Virtual Zoo Program
Back to Classes

88
90
91
92
93
93
95
96
100

6. Inheritance . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
A Primer on Inheritance
Overriding Instance Methods
Constructor Methods in Subclasses
Preventing Classes from Being Extended and Methods
from Being Overridden

vi |

Table of Contents

101
105
108
112

Subclassing Built-in Classes
The Theory of Inheritance
Abstract Not Supported
Using Inheritance in the Virtual Zoo Program
Virtual Zoo Program Code
It’s Runtime!

113
114
120
121
126
129

7. Compiling and Running a Program . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
Compiling with the Flash Authoring Tool
Compiling with Flex Builder 2
Compiling with mxmlc
Compiler Restrictions
The Compilation Process and the Classpath
Strict-Mode Versus Standard-Mode Compilation
The Fun’s Not Over

130
131
133
134
134
135
136

8. Datatypes and Type Checking . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 137
Datatypes and Type Annotations
Untyped Variables, Parameters, Return Values, and Expressions
Strict Mode’s Three Special Cases
Warnings for Missing Type Annotations
Detecting Reference Errors at Compile Time
Casting
Conversion to Primitive Types
Default Variable Values
null and undefined
Datatypes in the Virtual Zoo
More Datatype Study Coming Up

138
142
143
144
145
146
150
153
153
154
158

9. Interfaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
The Case for Interfaces
Interfaces and Multidatatype Classes
Interface Syntax and Use
Another Multiple-Type Example
More Essentials Coming

159
161
162
165
171

10. Statements and Operators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
Statements
Operators
Up Next: Managing Lists of Information

172
174
185
Table of Contents |

vii

11. Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186
What Is an Array?
The Anatomy of an Array
Creating Arrays
Referencing Array Elements
Determining the Size of an Array
Adding Elements to an Array
Removing Elements from an Array
Checking the Contents of an Array with the toString( ) Method
Multidimensional Arrays
On to Events

186
187
187
189
191
193
197
199
200
201

12. Events and Event Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202
ActionScript Event Basics
Accessing the Target Object
Accessing the Object That Registered the Listener
Preventing Default Event Behavior
Event Listener Priority
Event Listeners and Memory Management
Custom Events
Type Weakness in ActionScript’s Event Architecture
Handling Events Across Security Boundaries
What’s Next?

202
209
212
213
214
216
221
233
236
240

13. Exceptions and Error Handling . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 241
The Exception-Handling Cycle
Handling Multiple Types of Exceptions
Exception Bubbling
The finally Block
Nested Exceptions
Control-Flow Changes in try/catch/finally
Handling a Built-in Exception
More Gritty Work Ahead

241
244
253
258
260
264
267
268

14. Garbage Collection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 269
Eligibility for Garbage Collection
Incremental Mark and Sweep
Disposing of Objects Intentionally
Deactivating Objects

viii |

Table of Contents

269
272
273
274


Related documents


oreilly essential actionscript 3 0 jun 2007
javasyllabus
objectorientedprogrammingunit6
devry comp 220 ilab 7 polymorphism lab
csharp language specification
midterm answer


Related keywords