ActionScript 3.0 Cookbook: Solutions for Flash Platform and Flex Application Developers (Paperback)

Joey Lott, Darron Schall, Keith Peters

  • 出版商: O'Reilly
  • 出版日期: 2006-10-31
  • 定價: $1,380
  • 售價: 5.0$690
  • 語言: 英文
  • 頁數: 588
  • 裝訂: Paperback
  • ISBN: 0596526954
  • ISBN-13: 9780596526955
  • 相關分類: ActionScript & FLASH
  • 立即出貨 (庫存 < 4)

買這商品的人也買了...

相關主題

商品描述

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

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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

11. 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

12. 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

13. 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

14. 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

15. 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

16. 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

17. 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

18. 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

19. 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

20. 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

21. 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

22. Building Integrated Applications

      22.1 Calling JavaScript Functions

      22.2 Calling ActionScript Functions

      22.3 Passing Parameters from HTML

23. 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

24. 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

商品描述(中文翻譯)

描述





在 Ajax 和 Microsoft 的 Windows Presentation Foundation 出現之前,Macromedia 提供了第一種使用基於 Flash 的「豐富互聯網應用程式」(Rich Internet Applications)建立具有桌面程式的響應性和功能的網頁的方法。現在,新的所有者 Adobe 正將 Flash 及其強大的功能推向 Web 以外,使其成為一個完整的開發環境。


《ActionScript 3.0 Cookbook》不僅僅關注理論,還專注於 ActionScript 的實際應用,提供了超過 300 個解決常見編碼困境的解決方案。您將找到以下示例:



  • 檢測用戶的 Flash Player 版本或操作系統

  • 構建自定義類

  • 格式化日期和貨幣類型

  • 處理字符串

  • 構建用戶界面組件

  • 處理音頻和視頻

  • 使用 Flash Remoting 和 Web 服務進行遠程過程調用

  • 加載、發送和搜索 XML 數據

  • 以及更多...


每個代碼示例都提供了問題、解決方案和討論,以便您可以了解如何以其他方式使用它或根據自己的需求進行個性化,以及它的工作原理。您可以快速找到與您情況最相符的示例並獲得解決方案,而無需閱讀整本書以理解底層代碼。解決方案從解決小問題的短示例進展到解決更複雜問題的腳本,討論還提供了更深入的分析,以解決未來類似問題,以及可能的設計選擇和影響。您甚至還將學習如何將模塊化的 ActionScript 組件連接在一起,為 Flex 2 和 Flash 應用程序創建堅固的解決方案。


當您不確定 ActionScript 3.0 的工作原理或如何解決特定的編程困境時,您只需拿起這本書,翻到相關的示例,並快速找到您正在尋找的解決方案。



 



目錄



前言


1. ActionScript 基礎知識

      1.1 創建 ActionScript 專案

      1.2 自定義應用程序的屬性

      1.3 放置 ActionScript 代碼的位置

      1.4 如何追蹤消息

      1.5 處理事件

   
  1.6 響應滑鼠和鍵盤事件

      1.7 使用數學運算符

      1.8 檢查相等性或比較值

      1.9 條件性執行操作

      1.10 執行複雜的條件測試

      1.11 多次重複操作

      1.12 按時間重複任務

      1.13 創建可重用代碼

 
    1.14 將方法泛化