ActionScript 3.0 Cookbook(影印版)
ActionScript 3.0 Cookbook(影印版)
Joey Lott, Darron Schall, Keith Peters
出版时间:2007年07月
页数:556
当你需要使用Adobe Flash或者Adobe Flex软件快速完成一件任务时,《ActionScript 3.0 Cookbook》就应该是你身边触手可及的那本书。本书容纳了300余项深入具体细节的问题解决方案,是你解决ActionScript 3.0相关疑问的一站式答案宝库。
《ActionScript 3.0 Cookbook》提供了快速查询条目(有交叉参考),包括了应对下列挑战的解决方案:
*检测用户的Flash播放器或操作系统的版本
*格式化日期和货币类型
*接受用户输入和操作文本字符串
*运行时绘制图形
*访问音频和视频
*使用Flash Remoting进行远程过程调用(RPC)
*加载、发送和搜索XML数据
秉承O'Reilly广受欢迎的Cookbook系列所特有的“问题/解决方案/讨论”模式,本书提供了每个问题对应的解决方案以及为何如此实施的简要说明,因此你可以将其运用到将来类似的场景中去。对于那些声称“我知道所有理论,但我不知从何做起”的人们来说,本书针对真实世界里Flash和Flex 2开发者们天天碰到的那些问题提供了完备的答案。
Joey Lott是一位在Flash社区中主要的演讲者和技术顾问,同时还是O'Reilly的《Flash 8 Cookbook》一书的作者。Darron Schall是专门从事Rich Internet Applications (RIA)和Flash平台开发的技术顾问。Keith Peters是一位获奖的专职Flash开发独立工作者。
  1. Preface
  2. 1. ActionScript Basics
  3. 1.1 Creating an ActionScript Project
  4. 1.2 Customizing the Properties of an Application
  5. 1.3 Where to Place ActionScript Code
  6. 1.4 How to Trace a Message
  7. 1.5 Handling Events
  8. 1.6 Responding to Mouse and Key Events
  9. 1.7 Using Mathematical Operators
  10. 1.8 Checking Equality or Comparing Values
  11. 1.9 Performing Actions Conditionally
  12. 1.10 Performing Complex Conditional Testing
  13. 1.11 Repeating an Operation Many Times
  14. 1.12 Repeating a Task over Time
  15. 1.13 Creating Reusable Code
  16. 1.14 Generalizing a Method to Enhance Reusability
  17. 1.15 Exiting a Method
  18. 1.16 Obtaining the Result of a Method
  19. 1.17 Handling Errors
  20. 2. Custom Classes
  21. 2.1 Creating a Custom Class
  22. 2.2 Determining Where to Save a Class
  23. 2.3 Creating Properties That Behave As Methods
  24. 2.4 Creating Static Methods and Properties
  25. 2.5 Creating Subclasses
  26. 2.6 Implementing Subclass Versions of Superclass Methods
  27. 2.7 Creating Constants
  28. 2.8 Dispatching Events
  29. 3. Runtime Environment
  30. 3.1 Detecting the Player Version
  31. 3.2 Detecting the Operating System
  32. 3.3 Checking the Player Type
  33. 3.4 Checking the System Language
  34. 3.5 Detecting Display Settings
  35. 3.6 Scaling the Movie
  36. 3.7 Changing the Alignment
  37. 3.8 Hiding the Flash Player’s Menu Items
  38. 3.9 Detecting the Device’s Audio Capabilities
  39. 3.10 Detecting the Device’s Video Capabilities
  40. 3.11 Prompting the User to Change Player Settings
  41. 3.12 Dealing with System Security
  42. 4. Numbers and Math
  43. 4.1 Representing Numbers in Different Bases
  44. 4.2 Converting Between Different Number Systems
  45. 4.3 Rounding Numbers
  46. 4.4 Inserting Leading or Trailing Zeros or Spaces
  47. 4.5 Formatting Numbers for Display Without a Mask
  48. 4.6 Formatting Currency Amounts
  49. 4.7 Generating a Random Number
  50. 4.8 Simulating a Coin Toss
  51. 4.9 Simulating Dice
  52. 4.10 Simulating Playing Cards
  53. 4.11 Generating a Unique Number
  54. 4.12 Converting Angle Measurements
  55. 4.13 Calculating the Distance Between Two Points
  56. 4.14 Determining Points Along a Circle
  57. 4.15 Converting Between Units of Measurement
  58. 5. Arrays
  59. 5.1 Adding Elements to the Start or End of an Array
  60. 5.2 Looping Through an Array
  61. 5.3 Searching for Matching Elements in an Array
  62. 5.4 Removing Elements
  63. 5.5 Inserting Elements in the Middle of an Array
  64. 5.6 Converting a String to an Array
  65. 5.7 Converting an Array to a String
  66. 5.8 Creating a Separate Copy of an Array
  67. 5.9 Storing Complex or Multidimensional Data
  68. 5.10 Sorting or Reversing an Array
  69. 5.11 Implementing a Custom Sort
  70. 5.12 Randomizing the Elements of an Array
  71. 5.13 Getting the Minimum or Maximum Element
  72. 5.14 Comparing Arrays
  73. 5.15 Creating an Associative Array
  74. 5.16 Reading Elements of an Associative Array
  75. 6. Display List
  76. 6.1 Adding an Item to the Display List
  77. 6.2 Removing an Item from the Display List
  78. 6.3 Moving Objects Forward and Backward
  79. 6.4 Creating Custom Visual Classes
  80. 6.5 Creating Simple Buttons
  81. 6.6 Loading External Images at Runtime
  82. 6.7 Loading and Interacting with External Movies
  83. 6.8 Creating Mouse Interactions
  84. 6.9 Dragging and Dropping Objects with the Mouse
  85. 7. Drawing and Masking
  86. 7.1 Setting a Line Style
  87. 7.2 Setting Gradient Line Styles
  88. 7.3 Drawing a Line
  89. 7.4 Drawing a Curve
  90. 7.5 Drawing an Arc
  91. 7.6 Drawing a Rectangle
  92. 7.7 Drawing a Circle
  93. 7.8 Drawing an Ellipse
  94. 7.9 Drawing a Triangle
  95. 7.10 Drawing Regular Polygons
  96. 7.11 Drawing a Star
  97. 7.12 Filling a Shape with a Solid or Translucent Color
  98. 7.13 Filling a Shape with a Gradient
  99. 7.14 Filling a Shape with a Bitmap
  100. 7.15 Scripting Masks
  101. 8. Bitmaps
  102. 8.1 Creating a BitmapData Object
  103. 8.2 Adding a Bitmap to the Display List
  104. 8.3 Drawing a Display Object to a Bitmap
  105. 8.4 Loading an External Image into a Bitmap
  106. 8.5 Manipulating Pixels
  107. 8.6 Creating Rectangular Fills
  108. 8.7 Creating a Flood Fill
  109. 8.8 Copying Pixels
  110. 8.9 Copying Channels
  111. 8.10 Creating Noise
  112. 8.11 Creating Perlin Noise
  113. 8.12 Using Threshold
  114. 8.13 Applying a Filter to a Bitmap
  115. 8.14 Dissolving Between Two Bitmaps
  116. 8.15 Scrolling a Bitmap
  117. 9. Text
  118. 9.1 Creating an Outline Around a Text Field
  119. 9.2 Creating a Background for a Text Field
  120. 9.3 Making a User Input Field
  121. 9.4 Making a Password Input Field
  122. 9.5 Filtering Text Input
  123. 9.6 Setting a Field’s Maximum Length
  124. 9.7 Displaying Text
  125. 9.8 Displaying HTML-Formatted Text
  126. 9.9 Condensing Whitespace
  127. 9.10 Sizing Text Fields to Fit Contents
  128. 9.11 Scrolling Text Programmatically
  129. 9.12 Responding to Scroll Events
  130. 9.13 Formatting Text
  131. 9.14 Formatting User-Input Text
  132. 9.15 Formatting a Portion of Existing Text
  133. 9.16 Setting a Text Field’s Font
  134. 9.17 Embedding Fonts
  135. 9.18 Creating Text That Can Be Rotated
  136. 9.19 Displaying Unicode Text
  137. 9.20 Assigning Focus to a Text Field
  138. 9.21 Selecting Text with ActionScript
  139. 9.22 Setting the Insertion Point in a Text Field
  140. 9.23 Responding When Text Is Selected or Deselected
  141. 9.24 Responding to User Text Entry
  142. 9.25 Adding a Hyperlink to Text
  143. 9.26 Calling ActionScript from Hyperlinks
  144. 9.27 Working with Advanced Text Layout
  145. 9.28 Applying Advanced Anti-Aliasing
  146. 9.29 Replacing Text
  147. 9.30 Retrieving a List of System Fonts
  148. 10. Filters and Transforms
  149. 10.1 Applying Color Changes
  150. 10.2 Applying Color Tints
  151. 10.3 Resetting Color
  152. 10.4 Shearing
  153. 10.5 Applying Basic Filters
  154. 10.6 Applying Advanced Filter Effects (Emboss, etc.)
  155. 10.7 Embossing
  156. 10.8 Detecting Edges
  157. 10.9 Sharpening
  158. 10.10 Making a Digital Negative
  159. 10.11 Applying Grayscale
  160. 10.12 Changing Saturation
  161. 10.13 Changing Brightness
  162. 10.14 Changing Contrast
  163. 11. Programmatic Animation
  164. 11.1 Moving an Object
  165. 11.2 Moving an Object in a Specific Direction
  166. 11.3 Easing
  167. 11.4 Acceleration
  168. 11.5 Springs
  169. 11.6 Using Trigonometry
  170. 11.7 Applying Animation Techniques to Other Properties
  171. 12. Strings
  172. 12.1 Joining Strings
  173. 12.2 Using Quotes and Apostrophes in Strings
  174. 12.3 Inserting Special Whitespace Characters
  175. 12.4 Searching for a Substring
  176. 12.5 Extracting a Substring
  177. 12.6 Parsing a String into Words
  178. 12.7 Removing and Replacing Characters and Words
  179. 12.8 Retrieving One Character at a Time
  180. 12.9 Converting Case
  181. 12.10 Trimming Whitespace
  182. 12.11 Reversing a String by Word or by Character
  183. 12.12 Converting Between Strings and Unicode or ASCII
  184. 13. Regular Expressions
  185. 13.1 Understanding Regular Expression Patterns
  186. 13.2 Testing Regular Expressions
  187. 13.3 Looking for Pattern Matches
  188. 13.4 Removing and Replacing Characters and Words Using Patterns
  189. 13.5 Creating a Nongreedy Pattern
  190. 13.6 Validating User Input with Common Patterns
  191. 14. Dates and Times
  192. 14.1 Finding the Current Date and Time
  193. 14.2 Retrieving the Date Values
  194. 14.3 Retrieving the Day or Month Name
  195. 14.4 Formatting the Date and Time
  196. 14.5 Formatting Seconds or Milliseconds as Minutes and Seconds
  197. 14.6 Converting Between DMYHMSM and Epoch Milliseconds
  198. 14.7 Using Timers
  199. 14.8 Calculating Elapsed Time or Intervals Between Dates
  200. 14.9 Parsing a Date from a String
  201. 15. Programming Sound
  202. 15.1 Creating a Sound Object and Loading a Sound
  203. 15.2 Starting and Stopping a Sound
  204. 15.3 Setting the Buffer for a Sound
  205. 15.4 Offsetting the Start of a Sound
  206. 15.5 Playing a Sound Multiple Times (Looping)
  207. 15.6 Getting the Size of a Sound File
  208. 15.7 Reading the ID3 Tag of a Sound File
  209. 15.8 Find Out When a Sound Finishes Playing
  210. 15.9 Tracking the Progress of a Playing Sound
  211. 15.10 Pausing and Restarting a Sound
  212. 15.11 Reading the Level of a Sound
  213. 15.12 Stopping All Sounds
  214. 15.13 Reading the Sound Spectrum
  215. 15.14 Changing the Volume or Pan of a Sound
  216. 15.15 Creating a Sound Application
  217. 16. Video
  218. 16.1 Loading and Playing Back Video
  219. 16.2 Controlling Video Sound
  220. 16.3 Reading Playback Time
  221. 16.4 Reading Video Duration
  222. 16.5 Controlling Playback Time
  223. 16.6 Scaling Video
  224. 16.7 Managing and Monitoring Buffering and Loading
  225. 16.8 Listening for Cue Points
  226. 16.9 Applying Filters to Video
  227. 16.10 Pausing and Resuming Video
  228. 16.11 Stopping Video
  229. 16.12 Scrubbing Video
  230. 16.13 Clearing the Video Display
  231. 16.14 Determining User Bandwidth
  232. 17. Storing Persistent Data
  233. 17.1 Creating and Opening a Local Shared Object
  234. 17.2 Writing Data to a Shared Object
  235. 17.3 Saving a Local Shared Object
  236. 17.4 Reading Data from a Shared Object
  237. 17.5 Removing Data from a Shared Object
  238. 17.6 Serializing Custom Classes
  239. 17.7 Sharing Data Between Flash Applications
  240. 17.8 Controlling the Size of Local Shared Objects
  241. 18. Communicating with Other Movies
  242. 18.1 Creating Local Connections
  243. 18.2 Sending Data
  244. 18.3 Validating Receipt of Communication over Local Connections
  245. 18.4 Accepting Local Communications from Other Domains
  246. 19. Sending and Loading Data
  247. 19.1 Loading Variables from a Text File
  248. 19.2 Loading Variables from a Server-Side Script
  249. 19.3 Loading a Block of Text (Including HTML and XML)
  250. 19.4 Checking Load Progress
  251. 19.5 Accessing Data Being Downloaded
  252. 19.6 Sending Data to a Server-Side Script
  253. 19.7 Sending Variables and Handling a Returned Result
  254. 20. XML
  255. 20.1 Understanding XML Structure (Reading and Writing XML)
  256. 20.2 Creating an XML Object
  257. 20.3 Adding Elements to an XML Object
  258. 20.4 Adding Text Nodes to an XML Object
  259. 20.5 Adding Attributes to an XML Element
  260. 20.6 Reading Elements in an XML Tree
  261. 20.7 Finding Elements by Name
  262. 20.8 Reading Text Nodes and Their Values
  263. 20.9 Reading an Element’s Attributes
  264. 20.10 Removing Elements, Text Nodes, and Attributes
  265. 20.11 Loading XML
  266. 20.12 Loading XML from Different Domains
  267. 20.13 Sending XML
  268. 20.14 Searching XML
  269. 20.15 Using HTML and Special Characters in XML
  270. 21. Web Services and Flash Remoting
  271. 21.1 Calling Web Services Methods
  272. 21.2 Handling Web Services Responses
  273. 21.3 Handling Web Services Errors
  274. 21.4 Calling Flash Remoting Methods
  275. 21.5 Handling Flash Remoting Responses
  276. 22. Building Integrated Applications
  277. 22.1 Calling JavaScript Functions
  278. 22.2 Calling ActionScript Functions
  279. 22.3 Passing Parameters from HTML
  280. 23. File Management
  281. 23.1 Downloading Files
  282. 23.2 Detecting When a User Selects a File to Upload
  283. 23.3 Monitoring Download Progress
  284. 23.4 Browsing for Files
  285. 23.5 Filtering Files That Display in the Browser Window
  286. 23.6 Detecting When the User Has Selected a File to Upload
  287. 23.7 Uploading Files
  288. 23.8 Monitoring File Upload Progress
  289. 24. Socket Programming
  290. 24.1 Connecting to a Socket Server
  291. 24.2 Sending Data
  292. 24.3 Receiving Data
  293. 24.4 Handshaking with a Socket Server
  294. 24.5 Disconnecting from a Socket Server
  295. 24.6 Handling Socket Errors
  296. Appendix. Unicode Escape Sequences for Latin 1 Characters
  297. Index
书名:ActionScript 3.0 Cookbook(影印版)
国内出版社:东南大学出版社
出版时间:2007年07月
页数:556
书号:978-7-5641-0776-5
原版书出版商:O'Reilly Media
Joey Lott
 
Joey Lott 是O'Reilly出版的好几本有关 Macromedia 技术图书的作者,包括《Flash 8 Cookbook》、《Programming Flash Communication Server》,以及《ActionScript Cookbook》,也是《Flash 8 ActionScript Bible》(Wiley)和《Advanced ActionScript with Design Patterns》(Adobe Press,2006 年 10 月)的作者。Joey 从 1999 年起就在教授 Flash 和 ActionScript。他在互联网行业的专业经验,包括共同创立 RightSpring 公司,以及担任 YourMobile/Premium Wireless Services(J2EE B2C 应用程序)和 Ads.com(主导一个 J2EE B2B 应用程序的开发)的顾问。
Joey Lott is the author of several O'Reilly books on Macromedia technology,including Flash 8 Cookbook, Programming Flash Communication Server, and the ActionScript Cookbook. He is also the author of Flash 8 ActionScript Bible (Wiley) and Advanced ActionScript with Design Patterns (Adobe Press, October 2006). Joey has been teaching Flash and ActionScript since 1999. His professional experience in the Internet industry includes co-founding RightSpring, Inc., as well as consulting for YourMobile/Premium Wireless Services (J2EE B2C application) and Ads.com(leading the development of a J2EE B2B application).

Joey Lott is a founding partner in The Morphic Group (www.themorphicgroup.com),
specializing in Flex application development. Joey has also written many other leading
books on Flex and Flash-related technologies, including O’Reilly’s ActionScript 3.0
Cookbook.
 
 
Darron Schall
 
Darron Schall 是独立顾问,专长是 Flash 平台,毕业于 Lehigh 大学计算机科学系。他从早期就一直使用 ActionScript,在 Flash 和 Flex 社群中讲话很有份量。他积极参与 Flash 开源运动项目,从软件开发工具到Commodore 64 模拟器都有。Darron 在各种会议上演讲ActionScript,也对一些图书和杂志做出贡献。你可以在 http://www.darronschall.com 找到他有关 Flash 平台的博客。
Darron Schall is an independent consultant specializing in the Flash platform, with a Bachelor's Degree in Computer Science from Lehigh University. He has been using ActionScript since the early days and is a prominent voice in the Flash and Flex communities. He is actively involved in the Open Source Flash movement with projects ranging from software development tools to a Commodore 64 emulator.
Darron has spoken at various conferences about ActionScript and has contributed to books and magazines. You can find his Flash platform-related blog at http://www.darronschall.com.
 
 
Keith Peters
 
Keith Peters 是波士顿地区的 Flash 开发人员。他从 1999 年起就使用 Flash 工作,目前是 Brightcove 公司(http://www.brightcove.com)的资深 Flash 开发人员。Keith 对其他9本 Flash 和 ActionScript 图书做过贡献。他的个人网站(http://www.bit-101.com)有个很活跃的博客(超过 700 个开源 Flash 实验品,以及许多和 Flash 相关的资料)。
Keith Peters is a Flash developer in the Boston area. He has been working with Flash since 1999 and is currently a Senior Flash Developer at Brightcove(http://www.brightcove.com). Keith has been a contributing author to nine other Flash and ActionScript books. His personal web site,http://www.bit-101.com,features an active blog, more than 700 open source Flash experiments, and lots of other random Flash-related stuff.
 
 
The animal on the cover of ActionScript 3.0 Cookbook is a crab-eating opossum
(Philander opossum). It can be found throughout Mexico, Central America, and
South America. The length of the animal varies, though it is usually between 250 and 350 millimeters. Its prehensile tail often grows to about the same length.
P. opossum is an omnivore. It eats insects, lizards, eggs, worms, frogs, small mammals, and birds, along with seeds, bananas, and leaves. It reproduces all year round, although the number of offspring varies. During the dry summer months when food is scarce, the litters can be as few as one or two young, while as many as seven can be born during the more plentiful rainy season.
Most opossum nests are built in the low branches of trees, though they can also be found on the ground or in burrows. P. opossum spends most of its time on the forest floor, where it forages for food, though it will occasionally take to the trees. It was once thought that P. opossum was nocturnal, but it has often been observed scampering and foraging during the day. When it senses danger, P. opossum will hiss or yelp, and it can be a capable fighter.