ActionScript Cookbook

ActionScript Cookbook

by Joey Lott


$41.73 $49.95 Save 16% Current price is $41.73, Original price is $49.95. You Save 16%.

Temporarily Out of Stock Online

Eligible for FREE SHIPPING


ActionScript Cookbook by Joey Lott

When you need to get the job done fast, you'll reach for this practical, nuts-n-bolts toolkit. Rather than focusing on ActionScript in the abstract, this Cookbook puts theory into practice with ready-made answers to common ActionScript problems. Flash MX developers can solve issues quickly, while learning practical techniques for resolving similar dilemmas in the future.ActionScript has blossomed into a large and important language whose sheer volume of capabilities can be daunting. The ActionScript Cookbook breaks it all down into tasks that are relevant, practical, and insightful. Appealing to the budding coder as well as the experienced ActionScript jockeys, this book offers new perspectives and approaches to ActionScript development that will empower all developers.This O'Reilly Cookbook complements ActionScript for Flash MX: The Definitive Guide, 2nd Edition by providing quick solutions to common ActionScript problems. This book trades on our respected "Cookbook" approach, which provides a worked-out script for every problem addressed. You can use these "recipes" to solve an immediate problem, and then explore the issue further in The Definitive Guide when time permits.The ActionScript Cookbook contains over 300 recipes on a myriad of topics. Here's a sampling of what you'll find:

  • Drawing shapes at runtime
  • Controlling movie clips programmatically
  • Accepting user input and manipulating text strings
  • Accessing audio and video via Flash Communications Server
  • Working with Flash Remoting to connect to back end databases
  • Using record sets with data grids
  • And, much, much more in over 20 recipe-laden chapters...
This Cookbook's logical progression from short recipes for small problems to longer, more complex scripts for thornier riddles allows developers to link modular ActionScript pieces together to create rock-solid solutions for Flash applications. If you prefer to see larger applications instead of atomic recipes, this Cookbook has a kicker — seven full chapters of sample applications including:
  • Building a Flash Paint Application
  • Creating a Video/Chat Message Server Application
  • Creating an MP3 Jukebox
  • Creating a personalizable MyPage Application
The ActionScript Cookbook is for people who say, "I understand everything in theory, but I don't know where to start in practice." This book is all about practice.

Product Details

ISBN-13: 9780596004903
Publisher: O'Reilly Media, Incorporated
Publication date: 07/09/2003
Edition description: 1ST
Pages: 896
Product dimensions: 7.34(w) x 9.16(h) x 1.65(d)

About the Author

Joey Lott is the author of Complete Flash Remoting MX as well as the co-author of the ActionScript Bible. Joey has been teaching Flash and ActionScript since 1999 when he first began training throughout Southern California. Joey has professional experience in the Internet industry beginning in 1996 including co-founding RightSpring, Inc. and consulting for YourMobile/Premium Wireless Services (J2EE B2C application) and (leading the development of a J2EE B2B application).

Table of Contents

What’s Not in This Book;
Flash Naming Conventions;
The Code;
Typographical Conventions;
We’d Like to Hear from You;
Local Recipes;
Chapter 1: ActionScript Basics;
1.1 Introduction;
1.2 Using Mathematical Operators;
1.3 Checking Equality or Comparing Values;
1.4 Performing Actions Conditionally;
1.5 Performing Complex Conditional Testing;
1.6 Repeating an Operation Many Times;
1.7 Performing an Action Once per Frame Update;
1.8 Repeating a Task at Timed Intervals;
1.9 Creating Reusable Code;
1.10 Generalizing a Function to Enhance Reusability;
1.11 Exiting a Function;
1.12 Obtaining the Result of a Function;
1.13 Avoiding Conflicting Variables;
1.14 Reusing and Organizing Code in Multiple Movies;
Chapter 2: Runtime Environment;
2.1 Introduction;
2.2 Detecting the Player Version;
2.3 Detecting the Operating System;
2.4 Checking the System Language;
2.5 Detecting Display Settings;
2.6 Scaling the Movie;
2.7 Changing the Alignment;
2.8 Detecting the Device’s Audio Capabilities;
2.9 Prompting the User to Change Player Settings;
2.10 Hiding the Flash Player’s Menu Items;
2.11 Enhancing Standalone Projectors;
2.12 Setting the Dimensions of a Projector;
2.13 Specifying Where on Screen a Projector Opens;
Chapter 3: Color;
3.1 Introduction;
3.2 Setting the Color of a Movie Clip;
3.3 Specifying RGB Values;
3.4 Decoding an RGB Value;
3.5 Setting the RGB Relative to Its Current Value;
3.6 Tinting a Movie Clip’s Color;
3.7 Setting a Movie Clip’s Transparency;
3.8 Transforming a Movie Clip’s Current Color;
3.9 Restoring a Movie Clip’s Original Color;
3.10 Controlling a Movie Clip’s Color with Sliders;
Chapter 4: Drawing and Masking;
4.1 Introduction;
4.2 Drawing a Line;
4.3 Drawing a Curve;
4.4 Drawing a Rectangle;
4.5 Drawing a Rounded Rectangle;
4.6 Drawing a Circle;
4.7 Drawing an Ellipse;
4.8 Drawing a Triangle;
4.9 Drawing Regular Polygons;
4.10 Filling a Shape with a Solid or Translucent Color;
4.11 Filling a Shape with a Gradient;
4.12 Filling a Shape with a Complex Gradient;
4.13 Scripting Masks;
Chapter 5: Numbers and Math;
5.1 Introduction;
5.2 Representing Numbers in Different Bases;
5.3 Converting Between Different Number Systems;
5.4 Rounding Numbers;
5.5 Inserting Leading or Trailing Zeros;
5.6 Formatting Numbers for Display;
5.7 Formatting Currency Amounts;
5.8 Generating a Random Number;
5.9 Simulating a Coin Flip;
5.10 Simulating Dice;
5.11 Simulating Playing Cards;
5.12 Generating a Unique Number;
5.13 Converting Angle Measurements;
5.14 Calculating the Distance Between Two Points;
5.15 Determining Points Along a Circle;
5.16 Converting Between Units of Measurement;
5.17 Calculating Asset Appreciation (Future Value);
5.18 Calculating Retirement Savings;
5.19 Calculating the Loan (Mortgage) You Can Afford;
5.20 Calculating Loan Amortization or Annuities;
Chapter 6: Arrays;
6.1 Introduction;
6.2 Adding Elements to the Start or End of an Array;
6.3 Looping Through an Array;
6.4 Searching for Matching Elements in an Array;
6.5 Removing Elements;
6.6 Inserting Elements in the Middle of an Array;
6.7 Converting a String to an Array;
6.8 Converting an Array to a String;
6.9 Creating a Separate Copy of an Array;
6.10 Storing Complex or Multidimensional Data;
6.11 Sorting or Reversing an Array;
6.12 Implementing a Custom Sort;
6.13 Creating an Associative Array;
6.14 Reading Elements of an Associative Array;
Chapter 7: Movie Clips;
7.1 Introduction;
7.2 Referring to Movie Clips via ActionScript;
7.3 Targeting Movie Clips with Dynamic Names;
7.4 Affecting Playback;
7.5 Reversing Playback;
7.6 Using Movie Clips as Buttons;
7.7 Defining Hit Areas for Movie Clips;
7.8 Checking for Mouseover;
7.9 Performing Repeated Actions on Movie Clips;
7.10 Fading a Movie Clip;
7.11 Discovering Nested Movie Clips;
7.12 Getting Unique Depths;
7.13 Getting a Movie Clip’s Boundaries;
7.14 Creating a Draggable Movie Clip;
7.15 Creating a Custom Mouse Pointer;
7.16 Checking for Overlapping Movie Clips (Performing Hit Tests);
7.17 Changing Stacking Order;
7.18 Converting Between Coordinate Spaces;
7.19 Duplicating Movie Clips;
7.20 Adding Movie Clips from the Library with ActionScript;
Chapter 8: Text;
8.1 Introduction;
8.2 Referring to a Text Field via ActionScript;
8.3 Creating a Text Field;
8.4 Creating an Outline Around a Text Field;
8.5 Creating a Background for a Text Field;
8.6 Making a User Input Field;
8.7 Making a Password Input Field;
8.8 Filtering Text Input;
8.9 Restricting the Maximum Field Length;
8.10 Displaying Dynamic Text at Runtime;
8.11 Displaying HTML-Formatted Text;
8.12 Condensing Whitespace;
8.13 Sizing Text Fields to Fit Contents;
8.14 Scrolling Text with the ScrollBar Component;
8.15 Scrolling Text Programmatically;
8.16 Responding to Scroll Events;
8.17 Formatting Existing Text;
8.18 Formatting User-Input Text;
8.19 Formatting a Portion of a Text Field;
8.20 Setting a Text Field’s Font;
8.21 Embedding Fonts;
8.22 Creating Text That Can Be Rotated;
8.23 Displaying Unicode Text;
8.24 Assigning Focus to a Text Field;
8.25 Selecting Text with ActionScript;
8.26 Setting the Insertion Point in a Text Field;
8.27 Responding When Text Is Selected or Deselected;
8.28 Responding to User Text Entry;
8.29 Adding a Hyperlink to Text;
Chapter 9: Strings;
9.1 Introduction;
9.2 Joining Strings;
9.3 Using Quotes and Apostrophes in Strings;
9.4 Inserting Special Whitespace Characters;
9.5 Searching for a Substring;
9.6 Extracting a Substring;
9.7 Matching Patterns with Regular Expressions;
9.8 Looking for a Pattern Match;
9.9 Parsing a String into Words;
9.10 Removing and Replacing Characters;
9.11 Processing One Character at a Time;
9.12 Converting Case;
9.13 Trimming Whitespace;
9.14 Reversing a String by Word or by Letter;
9.15 Converting Between Strings and Unicode or ASCII;
Chapter 10: Dates and Times;
10.1 Introduction;
10.2 Finding the Current Date and Time;
10.3 Retrieving the Day or Month Name;
10.4 Formatting the Date and Time;
10.5 Formatting Milliseconds as Minutes and Seconds;
10.6 Converting Between DMYHMSM and Epoch Milliseconds;
10.7 Calculating Elapsed Time or Intervals Between Dates;
10.8 Parsing a Date from a String;
10.9 Creating Timers and Clocks;
Chapter 11: Forms;
11.1 Introduction;
11.2 Adding UI Components at Runtime;
11.3 Positioning Form Elements;
11.4 Adding Menus to a Form;
11.5 Making Dependent Menus;
11.6 Resizing Menus to Fit Their Contents;
11.7 Detecting the Selected Menu Items;
11.8 Adding Radio Buttons to a Group;
11.9 Aligning Radio Buttons Automatically;
11.10 Getting the Selected Radio Button Value;
11.11 Adding Checkboxes to a Form;
11.12 Getting Checkbox Values;
11.13 Assembling an Advanced Form;
11.14 Submitting a Form;
11.15 Validating Form Input;
11.16 Alerting Users to Validation Errors;
11.17 Making a Multipage Form;
11.18 Submitting a Multipage Form;
11.19 Validating a Multipage Form;
11.20 Transmitting Data Securely;
11.21 Prepopulating a Form;
11.22 Customizing the Tab Order;
11.23 Using Tables to Arrange Form Elements;
11.24 Creating Auto-Complete Text Fields;
11.25 Customizing a Component’s Appearance;
11.26 Customizing All Components’ Appearances;
Chapter 12: Objects and Custom Components;
12.1 Introduction;
12.2 Using Methods and Properties of Built-in Objects;
12.3 Creating an Instance of a Class;
12.4 Adding Properties to an Object Instance;
12.5 Adding Custom Methods to an Object Instance;
12.6 Creating a Custom Class;
12.7 Creating Smart Getter/Setter Properties;
12.8 Defining Read-Only Properties;
12.9 Creating Subclasses;
12.10 Implementing Subclass Versions of Superclass Methods;
12.11 Listening for Events;
12.12 Adding Listeners to Custom Classes;
12.13 Creating a Component That Subclasses MovieClip;
12.14 Program: Color Selector Component;
Chapter 13: Programming Sound;
13.1 Introduction;
13.2 Creating an Object to Control Sound;
13.3 Attaching Sounds at Runtime;
13.4 Playing and Stopping a Sound;
13.5 Getting Playback Time;
13.6 Looping a Sound;
13.7 Setting In and Out Points;
13.8 Pausing and Resuming a Sound;
13.9 Performing Actions When a Sound Ends;
13.10 Queuing Sounds;
13.11 Adding Sounds to Buttons and UI Components;
13.12 Setting the Volume of a Sound;
13.13 Controlling the Panning of a Sound;
13.14 Creating Advanced Stereo Panning Effects;
13.15 Fading In a Sound;
13.16 Fading Out a Sound;
13.17 Program: A Sound Controller Component;
Remote Recipes;
Chapter 14: FlashCom Server;
14.1 Introduction;
14.2 Creating a New FlashCom Application;
14.3 Connecting to the FlashCom Server;
14.4 Adding a Video Object at Runtime;
14.5 Capturing and Displaying Video from a Web Cam;
14.6 Capturing and Playing Audio from a Microphone;
14.7 Controlling FlashCom Audio;
14.8 Subscribing to Audio/Video Content;
14.9 Creating Playlists;
14.10 Recording and Publishing Video and Audio;
14.11 Publishing Live Content;
14.12 Pausing and Resuming a Net Stream;
14.13 Fast-Forwarding and Rewinding a Net Stream;
14.14 Seeking Relative to the Total Stream Length;
14.15 Implementing Server-Side ActionScript;
14.16 Tracking Clients Connected to the Application;
14.17 Invoking Server-Side Functions from the Client Movie;
14.18 Invoking Client-Side Functions from the Server;
Chapter 15: Loading Assets;
15.1 Introduction;
15.2 Loading an External SWF;
15.3 Loading an External SWF from a Trusting Domain;
15.4 Loading an External JPEG Image;
15.5 Loading an External Image (All Formats);
15.6 Loading an External MP3 Sound;
15.7 Loading Remote Content by Proxy;
15.8 Determining if an Asset Is Loaded;
15.9 Getting the Percentage of an Asset That Has Loaded;
15.10 Monitoring Load Progress Using a Progress Bar Component;
15.11 Monitoring Load Progress Without a Progress Bar Component;
15.12 Performing Actions When the Asset Is Loaded;
15.13 Hiding the Graphics and Text for a Progress Bar;
Chapter 16: Storing Persistent Information;
16.1 Introduction;
16.2 Storing and Retrieving Locally Persistent Information;
16.3 Adding Data to a Client-Side Shared Object;
16.4 Reading Values from a Client-Side Shared Object;
16.5 Saving a Local Shared Object;
16.6 Sharing Information Between Movies Within the Same Domain;
16.7 Storing Persistent Data on the Server;
16.8 Saving Remote Shared Object Data;
16.9 Checking for Updates to Remote Shared Objects;
16.10 Reading Values from a Server-Side Shared Object;
16.11 Adding Data to a Server-Side Shared Object;
Chapter 17: Communicating with Other Movies;
17.1 Introduction;
17.2 Communicating with Other Movieson the Same Computer;
17.3 Sending Data Using Local Connections;
17.4 Validating Receipt of Communication Over a Local Connection;
17.5 Accepting Communications from Other Domains;
17.6 Communicating Between Movies on Different Computers;
17.7 Broadcasting Data to Remote Shared Object Clients;
Chapter 18: Sending and Loading Variables;
18.1 Introduction;
18.2 Loading Variables from a Text File;
18.3 Loading Variables from a Server-Side Script;
18.4 Checking Load Progress;
18.5 Sending Data to a Server-Side Script;
18.6 Sending Variables and Handling a Returned Result;
Chapter 19: XML;
19.1 Introduction;
19.2 Understanding XML Structure (Reading and Writing XML);
19.3 Creating an XML Object;
19.4 Adding Elements to an XML Object;
19.5 Adding Text Nodes to an XML Object;
19.6 Creating an XML Object from an Array;
19.7 Adding Attributes to an XML Element;
19.8 Reading Elements in an XML Tree;
19.9 Finding Elements by Name;
19.10 Reading Text Nodes and Their Values;
19.11 Reading an Element’s Attributes;
19.12 Loading XML;
19.13 Removing Extra Whitespace from XML Objects;
19.14 Sending XML;
19.15 Sending XML Data and Receiving a Response;
19.16 Searching XML;
19.17 Using XML Data to Initialize a Movie;
Chapter 20: Flash Remoting;
20.1 Introduction;
20.2 Establishing a Connection via Flash Remoting;
20.3 Configuring Flash Remoting for ColdFusion;
20.4 Configuring Flash Remoting for .NET;
20.5 Configuring Flash Remoting for J2EE;
20.6 Configuring Flash Remoting for PHP or Perl;
20.7 Invoking a Remote Function on a Service;
20.8 Handling Flash Remoting Results;
20.9 Distinguishing Among Results from Multiple Calls to a Single Service;
20.10 Calling ASP.NET Functions from Flash;
20.11 Calling ColdFusion Functions from Flash;
20.12 Passing Named Parameters to ColdFusion Component Methods;
20.13 Passing Complex Parameters to ColdFusion Component Methods;
20.14 Calling Java or JSP Functions from Flash;
20.15 Transmitting Custom Datatypes to a Flash Remoting Back End;
20.16 Receiving Typed Objects with ColdFusion;
20.17 Receiving Typed Objects with ASP.NET;
20.18 Receiving Typed Objects with Java;
20.19 Returning Typed Objects from ColdFusion;
20.20 Returning Typed Objects from ASP.NET;
20.21 Returning Typed Objects from Java;
20.22 Writing Server-Side Functions in ActionScript;
20.23 Querying a Database with Server-Side ActionScript;
20.24 Making HTTP Requests with Server-Side ActionScript;
20.25 Consuming Web Services with Flash Remoting for .NET or ColdFusion;
Chapter 21: Recordsets;
21.1 Introduction;
21.2 Creating Recordsets;
21.3 Reading Recordsets;
21.4 Filtering Recordsets;
21.5 Sorting Recordsets by a Single Column;
21.6 Populating Menu Components;
21.7 Using Recordsets with DataGrids;
Chapter 22: Building a Flash Paint Application;
22.1 Planning the Application;
22.2 Building the Components;
22.3 Assembling the Flash Paint Application;
22.4 Using Flash Paint;
Chapter 23: Creating a Simple Animation in Stages;
23.1 Stage One;
23.2 Stage Two;
23.3 Stage Three;
23.4 Stage Four;
23.5 Stage Five;
23.6 Conclusion;
Chapter 24: Video Chat/Message Center;
24.1 Developing the Application Overview;
24.2 Creating the Server-Side Application;
24.3 Creating the Calling Client;
24.4 Creating the Administrator Client;
24.5 Putting It All Together;
Chapter 25: Image Viewer/Slideshow;
25.1 Planning the Application Design;
25.2 Beginning the Application;
25.3 Creating the Components;
25.4 Putting Together the Application;
25.5 Wrapping It Up;
Chapter 26: Creating an MP3 Jukebox;
26.1 Creating an Application Overview;
26.2 Developing the MP3 Selectors;
26.3 Developing the Jukebox Application;
26.4 Wrapping It Up;
Chapter 27: A Personalized My Page Application;
27.1 Formulating the Application Overview;
27.2 Creating the Framework;
27.3 Creating Service Modules;
27.4 Putting It All Together;
27.5 Extending the Framework;
27.6 Wrapping It Up;
Chapter 28: A Scheduler Program;
28.1 Designing the Application Structure;
28.2 Making the Components;
28.3 Putting the Application Together;
28.4 Making the Scheduler Application Available Online;
28.5 Using LoadVars and XML;
28.6 Wrapping It Up;
Unicode Escape Sequences for Latin 1 Characters;

Customer Reviews

Most Helpful Customer Reviews

See All Customer Reviews