ActionScript 3.0 Cookbook: Solutions for Flash Platform and Flex Application Developers (Paperback)
內容描述
Description
Well before Ajax and Microsoft's Windows Presentation Foundation hit the
scene, Macromedia offered the first method for building web pages with the
responsiveness and functionality of desktop programs with its Flash-based
"Rich Internet Applications". Now, new owner Adobe is taking Flash and its
powerful capabilities beyond the Web and making it a full-fledged development
environment.
Rather than focus on theory, the ActionScript 3.0 Cookbook concentrates on
the practical application of ActionScript, with more than 300 solutions you
can use to solve a wide range of common coding dilemmas. You'll find recipes
that show you how to:
Detect the user's Flash Player version or their operating system
Build custom classes
Format dates and currency types
Work with strings
Build user interface components
Work with audio and video
Make remote procedure calls using Flash Remoting and web services
Load, send, and search XML data
And much, much more ...
Each code recipe presents the Problem, Solution, and Discussion of how you
can use it in other ways or personalize it for your own needs, and why it
works. You can quickly locate the recipe that most closely matches your
situation and get the solution without reading the whole book to understand
the underlying code. Solutions progress from short recipes for small problems
to more complex scripts for thornier riddles, and the discussions offer a
deeper analysis for resolving similar issues in the future, along with
possible design choices and ramifications. You'll even learn how to link
modular ActionScript pieces together to create rock-solid solutions for Flex 2
and Flash applications.
When you're not sure how ActionScript 3.0 works or how to approach a
specific programming dilemma, you can simply pick up the book, flip to the
relevant recipe(s), and quickly find the solution you're looking
for.
Table of Contents
Preface
- ActionScript Basics 1.1 Creating an
ActionScript Project 1.2 Customizing the
Properties of an Application 1.3 Where to Place
ActionScript Code 1.4 How to Trace a
Message 1.5 Handling Events
1.6 Responding to Mouse and Key Events 1.7
Using Mathematical Operators 1.8 Checking
Equality or Comparing Values 1.9 Performing
Actions Conditionally 1.10 Performing Complex
Conditional Testing 1.11 Repeating an Operation
Many Times 1.12 Repeating a Task over
Time 1.13 Creating Reusable Code
1.14 Generalizing a Method to Enhance Reusability
1.15 Exiting a Method 1.16
Obtaining the Result of a Method 1.17 Handling
Errors - Custom Classes 2.1 Creating a Custom
Class 2.2 Determining Where to Save a
Class 2.3 Creating Properties That Behave As
Methods 2.4 Creating Static Methods and
Properties 2.5 Creating Subclasses
2.6 Implementing Subclass Versions of Superclass Methods
2.7 Creating Constants 2.8
Dispatching Events - Runtime Environment 3.1 Detecting
the Player Version 3.2 Detecting the Operating
System 3.3 Checking the Player Type
3.4 Checking the System Language
3.5 Detecting Display Settings 3.6 Scaling
the Movie 3.7 Changing the Alignment
3.8 Hiding the Flash Player's Menu Items
3.9 Detecting the Device's Audio Capabilities
3.10 Detecting the Device's Video Capabilities
3.11 Prompting the User to Change Player Settings
3.12 Dealing with System Security - Numbers and Math 4.1 Representing
Numbers in Different Bases 4.2 Converting Between
Different Number Systems 4.3 Rounding
Numbers 4.4 Inserting Leading or Trailing Zeros
or Spaces 4.5 Formatting Numbers for Display
Without a Mask 4.6 Formatting Currency
Amounts 4.7 Generating a Random Number
4.8 Simulating a Coin Toss
4.9 Simulating Dice 4.10 Simulating Playing
Cards 4.11 Generating a Unique Number
4.12 Converting Angle Measurements
4.13 Calculating the Distance Between Two Points
4.14 Determining Points Along a Circle
4.15 Converting Between Units of Measurement - Arrays 5.1 Adding Elements to the
Start or End of an Array 5.2 Looping Through an
Array 5.3 Searching for Matching Elements in an
Array 5.4 Removing Elements
5.5 Inserting Elements in the Middle of an Array
5.6 Converting a String to an Array 5.7
Converting an Array to a String 5.8 Creating a
Separate Copy of an Array 5.9 Storing Complex or
Multidimensional Data 5.10 Sorting or Reversing
an Array 5.11 Implementing a Custom Sort
5.12 Randomizing the Elements of an Array
5.13 Getting the Minimum or Maximum Element
5.14 Comparing Arrays 5.15 Creating
an Associative Array 5.16 Reading Elements of an
Associative Array - Display List 6.1 Adding an Item to
the Display List 6.2 Removing an Item from the
Display List 6.3 Moving Objects Forward and
Backward 6.4 Creating Custom Visual
Classes 6.5 Creating Simple Buttons
6.6 Loading External Images at Runtime
6.7 Loading and Interacting with External Movies
6.8 Creating Mouse Interactions 6.9
Dragging and Dropping Objects with the Mouse - Drawing and Masking 7.1 Setting a
Line Style 7.2 Setting Gradient Line
Styles 7.3 Drawing a Line
7.4 Drawing a Curve 7.5 Drawing an
Arc 7.6 Drawing a Rectangle
7.7 Drawing a Circle 7.8 Drawing an
Ellipse 7.9 Drawing a Triangle
7.10 Drawing Regular Polygons 7.11
Drawing a Star 7.12 Filling a Shape with a Solid
or Translucent Color 7.13 Filling a Shape with a
Gradient 7.14 Filling a Shape with a
Bitmap 7.15 Scripting Masks - Bitmaps 8.1 Creating a BitmapData
Object 8.2 Adding a Bitmap to the Display
List 8.3 Drawing a Display Object to a
Bitmap 8.4 Loading an External Image into a
Bitmap 8.5 Manipulating Pixels
8.6 Creating Rectangular Fills 8.7
Creating a Flood Fill 8.8 Copying Pixels
8.9 Copying Channels 8.10
Creating Noise 8.11 Creating Perlin Noise
8.12 Using Threshold 8.13
Applying a Filter to a Bitmap 8.14 Dissolving
Between Two Bitmaps 8.15 Scrolling a Bitmap - Text 9.1 Creating an Outline Around
a Text Field 9.2 Creating a Background for a Text
Field 9.3 Making a User Input Field
9.4 Making a Password Input Field
9.5 Filtering Text Input 9.6 Setting a
Field's Maximum Length 9.7 Displaying
Text 9.8 Displaying HTML-Formatted Text
9.9 Condensing Whitespace
9.10 Sizing Text Fields to Fit Contents 9.11
Scrolling Text Programmatically 9.12 Responding
to Scroll Events 9.13 Formatting Text
9.14 Formatting User-Input Text
9.15 Formatting a Portion of Existing Text
9.16 Setting a Text Field's Font 9.17 Embedding
Fonts 9.18 Creating Text That Can Be
Rotated 9.19 Displaying Unicode Text
9.20 Assigning Focus to a Text Field
9.21 Selecting Text with ActionScript
9.22 Setting the Insertion Point in a Text Field
9.23 Responding When Text Is Selected or Deselected
9.24 Responding to User Text Entry
9.25 Adding a Hyperlink to Text 9.26 Calling
ActionScript from Hyperlinks 9.27 Working with
Advanced Text Layout 9.28 Applying Advanced
Anti-Aliasing 9.29 Replacing Text
9.30 Retrieving a List of System Fonts - Filters and Transforms 10.1
Applying Color Changes 10.2 Applying Color
Tints 10.3 Resetting Color
10.4 Shearing 10.5 Applying Basic
Filters 10.6 Applying Advanced Filter Effects
(Emboss, etc.) 10.7 Embossing
10.8 Detecting Edges 10.9
Sharpening 10.10 Making a Digital
Negative 10.11 Applying Grayscale
10.12 Changing Saturation 10.13
Changing Brightness 10.14 Changing Contrast - Programmatic Animation 11.1 Moving
an Object 11.2 Moving an Object in a Specific
Direction 11.3 Easing
11.4 Acceleration 11.5 Springs
11.6 Using Trigonometry 11.7
Applying Animation Techniques to Other Properties - Strings 12.1 Joining
Strings 12.2 Using Quotes and Apostrophes in
Strings 12.3 Inserting Special Whitespace
Characters 12.4 Searching for a Substring
12.5 Extracting a Substring
12.6 Parsing a String into Words 12.7 Removing
and Replacing Characters and Words 12.8
Retrieving One Character at a Time 12.9
Converting Case 12.10 Trimming Whitespace
12.11 Reversing a String by Word or by Character
12.12 Converting Between Strings and Unicode or ASCII - Regular Expressions 13.1
Understanding Regular Expression Patterns 13.2
Testing Regular Expressions 13.3 Looking for
Pattern Matches 13.4 Removing and Replacing
Characters and Words Using Patterns 13.5 Creating
a Nongreedy Pattern 13.6 Validating User Input
with Common Patterns - Dates and Times 14.1 Finding the
Current Date and Time 14.2 Retrieving the Date
Values 14.3 Retrieving the Day or Month
Name 14.4 Formatting the Date and Time
14.5 Formatting Seconds or Milliseconds as Minutes and
Seconds 14.6 Converting Between DMYHMSM and Epoch
Milliseconds 14.7 Using Timers
14.8 Calculating Elapsed Time or Intervals Between Dates
14.9 Parsing a Date from a String - Programming Sound 15.1 Creating a
Sound Object and Loading a Sound 15.2 Starting
and Stopping a Sound 15.3 Setting the Buffer for
a Sound 15.4 Offsetting the Start of a
Sound 15.5 Playing a Sound Multiple Times
(Looping) 15.6 Getting the Size of a Sound
File 15.7 Reading the ID3 Tag of a Sound
File 15.8 Find Out When a Sound Finishes
Playing 15.9 Tracking the Progress of a Playing
Sound 15.10 Pausing and Restarting a
Sound 15.11 Reading the Level of a Sound
15.12 Stopping All Sounds
15.13 Reading the Sound Spectrum 15.14 Changing
the Volume or Pan of a Sound 15.15 Creating a
Sound Application - Video 16.1 Loading and Playing Back
Video 16.2 Controlling Video Sound
16.3 Reading Playback Time 16.4
Reading Video Duration 16.5 Controlling Playback
Time 16.6 Scaling Video
16.7 Managing and Monitoring Buffering and Loading
16.8 Listening for Cue Points 16.9
Applying Filters to Video 16.10 Pausing and
Resuming Video 16.11 Stopping Video
16.12 Scrubbing Video 16.13
Clearing the Video Display 16.14 Determining User
Bandwidth - Storing Persistent Data 17.1
Creating and Opening a Local Shared Object 17.2
Writing Data to a Shared Object 17.3 Saving a
Local Shared Object 17.4 Reading Data from a
Shared Object 17.5 Removing Data from a Shared
Object 17.6 Serializing Custom Classes
17.7 Sharing Data Between Flash Applications
17.8 Controlling the Size of Local Shared Objects - Communicating with Other Movies
18.1 Creating Local Connections 18.2 Sending
Data 18.3 Validating Receipt of Communication
over Local Connections 18.4 Accepting Local
Communications from Other Domains - Sending and Loading Data 19.1
Loading Variables from a Text File 19.2 Loading
Variables from a Server-Side Script 19.3 Loading
a Block of Text (Including HTML and XML) 19.4
Checking Load Progress 19.5 Accessing Data Being
Downloaded 19.6 Sending Data to a Server-Side
Script 19.7 Sending Variables and Handling a
Returned Result - XML 20.1 Understanding XML
Structure (Reading and Writing XML) 20.2 Creating
an XML Object 20.3 Adding Elements to an XML
Object 20.4 Adding Text Nodes to an XML
Object 20.5 Adding Attributes to an XML
Element 20.6 Reading Elements in an XML
Tree 20.7 Finding Elements by Name
20.8 Reading Text Nodes and Their Values
20.9 Reading an Element's Attributes 20.10
Removing Elements, Text Nodes, and Attributes
20.11 Loading XML 20.12 Loading XML from
Different Domains 20.13 Sending XML
20.14 Searching XML 20.15
Using HTML and Special Characters in XML - Web Services and Flash Remoting
21.1 Calling Web Services Methods 21.2 Handling
Web Services Responses 21.3 Handling Web Services
Errors 21.4 Calling Flash Remoting
Methods 21.5 Handling Flash Remoting
Responses - Building Integrated Applications
22.1 Calling JavaScript Functions 22.2 Calling
ActionScript Functions 22.3 Passing Parameters
from HTML - File Management 23.1 Downloading
Files 23.2 Detecting When a User Selects a File
to Upload 23.3 Monitoring Download
Progress 23.4 Browsing for Files
23.5 Filtering Files That Display in the Browser Window
23.6 Detecting When the User Has Selected a File to
Upload 23.7 Uploading Files
23.8 Monitoring File Upload Progress - Socket Programming 24.1 Connecting
to a Socket Server 24.2 Sending Data
24.3 Receiving Data 24.4
Handshaking with a Socket Server 24.5
Disconnecting from a Socket Server 24.6 Handling
Socket Errors
Appendix. Unicode Escape Sequences for Latin 1 Characters
Index