Actionscript 3.0 Cookbook.Pdf
Total Page:16
File Type:pdf, Size:1020Kb
ActionScript 3.0 Cookbook By Joey Lott, Darron Schall, Keith Peters ............................................... Publisher: O'Reilly Pub Date: October 01, 2006 ISBN: 0-596-52695-4 Pages: 592 Table of Contents | Index 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. ActionScript 3.0 Cookbook By Joey Lott, Darron Schall, Keith Peters ............................................... Publisher: O'Reilly Pub Date: October 01, 2006 ISBN: 0-596-52695-4 Pages: 592 Table of Contents | Index Preface Chapter 1. ActionScript Basics Section 1.0. Introduction Recipe 1.1. Creating an ActionScript Project Recipe 1.2. Customizing the Properties of an Application Recipe 1.3. Where to Place ActionScript Code Recipe 1.4. How to Trace a Message Recipe 1.5. Handling Events Recipe 1.6. Responding to Mouse and Key Events Recipe 1.7. Using Mathematical Operators Recipe 1.8. Checking Equality or Comparing Values Recipe 1.9. Performing Actions Conditionally Recipe 1.10. Performing Complex Conditional Testing Recipe 1.11. Repeating an Operation Many Times Recipe 1.12. Repeating a Task over Time Recipe 1.13. Creating Reusable Code Recipe 1.14. Generalizing a Method to Enhance Reusability Recipe 1.15. Exiting a Method Recipe 1.16. Obtaining the Result of a Method Recipe 1.17. Handling Errors Chapter 2. Custom Classes Section 2.0. Introduction Recipe 2.1. Creating a Custom Class Recipe 2.2. Determining Where to Save a Class Recipe 2.3. Creating Properties That Behave As Methods Recipe 2.4. Creating Static Methods and Properties Recipe 2.5. Creating Subclasses Recipe 2.6. Implementing Subclass Versions of Superclass Methods Recipe 2.7. Creating Constants Recipe 2.8. Dispatching Events Chapter 3. Runtime Environment Section 3.0. Introduction Recipe 3.1. Detecting the Player Version Recipe 3.2. Detecting the Operating System Recipe 3.3. Checking the Player Type Recipe 3.4. Checking the System Language Recipe 3.5. Detecting Display Settings Recipe 3.6. Scaling the Movie Recipe 3.7. Changing the Alignment Recipe 3.8. Hiding the Flash Player's Menu Items Recipe 3.9. Detecting the Device's Audio Capabilities Recipe 3.10. Detecting the Device's Video Capabilities Recipe 3.11. Prompting the User to Change Player Settings Recipe 3.12. Dealing with System Security Chapter 4. Numbers and Math Section 4.0. Introduction Recipe 4.1. Representing Numbers in Different Bases Recipe 4.2. Converting Between Different Number Systems Recipe 4.3. Rounding Numbers Recipe 4.4. Inserting Leading or Trailing Zeros or Spaces Recipe 4.5. Formatting Numbers for Display Without a Mask Recipe 4.6. Formatting Currency Amounts Recipe 4.7. Generating a Random Number Recipe 4.8. Simulating a Coin Toss Recipe 4.9. Simulating Dice Recipe 4.10. Simulating Playing Cards Recipe 4.11. Generating a Unique Number Recipe 4.12. Converting Angle Measurements Recipe 4.13. Calculating the Distance Between Two Points Recipe 4.14. Determining Points Along a Circle Recipe 4.15. Converting Between Units of Measurement Chapter 5. Arrays Section 5.0. Introduction Recipe 5.1. Adding Elements to the Start or End of an Array Recipe 5.2. Looping Through an Array Recipe 5.3. Searching for Matching Elements in an Array Recipe 5.4. Removing Elements Recipe 5.5. Inserting Elements in the Middle of an Array Recipe 5.6. Converting a String to an Array Recipe 5.7. Converting an Array to a String Recipe 5.8. Creating a Separate Copy of an Array Recipe 5.9. Storing Complex or Multidimensional Data Recipe 5.10. Sorting or Reversing an Array Recipe 5.11. Implementing a Custom Sort Recipe 5.12. Randomizing the Elements of an Array Recipe 5.13. Getting the Minimum or Maximum Element Recipe 5.14. Comparing Arrays Recipe 5.15. Creating an Associative Array Recipe 5.16. Reading Elements of an Associative Array Chapter 6. Display List Section 6.0. Introduction Recipe 6.1. Adding an Item to the Display List Recipe 6.2. Removing an Item from the Display List Recipe 6.3. Moving Objects Forward and Backward Recipe 6.4. Creating Custom Visual Classes Recipe 6.5. Creating Simple Buttons Recipe 6.6. Loading External Images at Runtime Recipe 6.7. Loading and Interacting with External Movies Recipe 6.8. Creating Mouse Interactions Recipe 6.9. Dragging and Dropping Objects with the Mouse Chapter 7. Drawing and Masking Section 7.0. Introduction Recipe 7.1. Setting a Line Style Recipe 7.2. Setting Gradient Line Styles Recipe 7.3. Drawing a Line Recipe 7.4. Drawing a Curve Recipe 7.5. Drawing an Arc Recipe 7.6. Drawing a Rectangle Recipe 7.7. Drawing a Circle Recipe 7.8. Drawing an Ellipse Recipe 7.9. Drawing a Triangle Recipe 7.10. Drawing Regular Polygons Recipe 7.11. Drawing a Star Recipe 7.12. Filling a Shape with a Solid or Translucent Color Recipe 7.13. Filling a Shape with a Gradient Recipe 7.14. Filling a Shape with a Bitmap Recipe 7.15. Scripting Masks Chapter 8. Bitmaps Section 8.0. Introduction Recipe 8.1. Creating a BitmapData Object Recipe 8.2. Adding a Bitmap to the Display List Recipe 8.3. Drawing a Display Object to a Bitmap Recipe 8.4. Loading an External Image into a Bitmap Recipe 8.5. Manipulating Pixels Recipe 8.6. Creating Rectangular Fills Recipe 8.7. Creating a Flood Fill Recipe 8.8. Copying Pixels Recipe 8.9. Copying Channels Recipe 8.10. Creating Noise Recipe 8.11. Creating Perlin Noise Recipe 8.12. Using Threshold Recipe 8.13. Applying a Filter to a Bitmap Recipe 8.14. Dissolving Between Two Bitmaps Recipe 8.15. Scrolling a Bitmap Chapter 9. Text Section 9.0. Introduction Recipe 9.1. Creating an Outline Around a Text Field Recipe 9.2. Creating a Background for a Text Field Recipe 9.3. Making a User Input Field Recipe 9.4. Making a Password Input Field Recipe 9.5. Filtering Text Input Recipe 9.6. Setting a Field's Maximum Length Recipe 9.7. Displaying Text Recipe 9.8. Displaying HTML-Formatted Text Recipe 9.9. Condensing Whitespace Recipe 9.10. Sizing Text Fields to Fit Contents Recipe 9.11. Scrolling Text Programmatically Recipe 9.12. Responding to Scroll Events Recipe 9.13. Formatting Text Recipe 9.14. Formatting User-Input Text Recipe 9.15. Formatting a Portion of Existing Text Recipe 9.16. Setting a Text Field's Font Recipe 9.17. Embedding Fonts Recipe 9.18. Creating Text that Can Be Rotated Recipe 9.19. Displaying Unicode Text Recipe 9.20. Assigning Focus to a Text Field Recipe 9.21. Selecting Text with ActionScript Recipe 9.22. Setting the Insertion Point in a Text Field Recipe 9.23. Responding When Text Is Selected or Deselected Recipe 9.24. Responding to User Text Entry Recipe 9.25. Adding a Hyperlink to Text Recipe 9.26. Calling ActionScript from Hyperlinks Recipe 9.27. Working with Advanced Text Layout Recipe 9.28. Applying Advanced Anti-Aliasing Recipe 9.29. Replacing Text Recipe 9.30. Retrieving a List of System Fonts Chapter 10. Filters and Transforms Section 10.0. Introduction Recipe 10.1. Applying Color Changes Recipe 10.2. Applying Color Tints Recipe 10.3. Resetting Color Recipe 10.4. Shearing Recipe 10.5. Applying Basic Filters Recipe 10.6. Applying Advanced Filter Effects (Emboss, etc.) Recipe 10.7. Embossing Recipe 10.8. Detecting Edges Recipe 10.9. Sharpening Recipe 10.10. Making a Digital Negative Recipe 10.11. Applying Grayscale Recipe 10.12. Changing Saturation Recipe 10.13. Changing Brightness Recipe 10.14. Changing Contrast Chapter 11. Programmatic Animation Section 11.0. Introduction Recipe 11.1. Moving an Object Recipe 11.2. Moving an Object in a Specific Direction Recipe 11.3. Easing Recipe 11.4. Acceleration Recipe 11.5. Springs Recipe 11.6. Using Trigonometry Recipe 11.7. Applying Animation Techniques to Other Properties Chapter 12.