CARVIEW |
ActionScript 3.0 Cookbook
Solutions for Flash Platform and Flex Application Developers
By Joey Lott, Darron Schall, Keith Peters
October 2006
Pages: 586
Series: Adobe Developer Library
ISBN 10: 0-596-52695-4 |
ISBN 13: 9780596526955
(Average of 17 Customer Reviews)
Well before Ajax and Windows Presentation Foundation, Macromedia Flash provided the first method for building "rich" web pages. Now, Adobe is making Flash a full-fledged development environment, and learning ActionScript 3.0 is key. That's a challenge for even the most experienced Flash developer. This Cookbook offers more than 300 solutions to solve a wide range of coding dilemmas, so you can learn to work with the new version right away.
Full Description
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.
Adobe Developer Library is a co-publishing partnership between O'Reilly Media and Adobe Systems, Inc. and is designed to produce the number one information resources for developers who use Adobe technologies. Created in 2006, the Adobe Developer Library is the official source for comprehensive learning solutions to help developers create expressive and interactive web applications that can reach virtually anyone on any platform. With top-notch books and innovative online resources covering the latest in rich Internet application development, the Adobe Developer Library offers expert training and in-depth resources, straight from the source.
Featured customer reviews
ActionScript 3.0 Cookbook, July 21 2008





Cookbook describes many subjects related to ActionScript. Book has very interesting form with chapters in not accidentally order. It starts with basics of programming, and then other topics which will give you the complex knowledge about ActionScript. Author is not getting into routine. In the table of contents you'll find specific tasks. Similar, when you trying to pass a practical exam. In one sentence the whole task. Which can have a different length and are divided in to a Problem, Solution, Discussion and See Also. The main advantage of this book is their form. Tasks can be very standard for example Using Mathematical Operators and less standard like Simulating Dice. Cookbook is not ordinary textbook to ActionScript 3.0 but it is a collection of typical and not typical solutions which can be found using this programming language. It would be useful to know the task's level of difficulty especially for beginner users. Sometimes we do not want to get knowledge about for example XML but only we try to solve the problem in a few minutes and this book exactly enables to do this.
Cookbook presents wonderful balance between form and contents. The chapter Web Services and Flash Remoting is worth mentioning. This book can be recommended to people who have to solve specific tasks.
book, June 01 2008





first oll of you you have been greeting after that really idon.t know the different books but i like cook books
Great resource for everyone serious about learning Action Script3, March 07 2008





As a student, I often need to explore elements of Action Script on my own. With the Cookbook, I can experiment on a model that I am able to manipulate. The Cookbook is written with an approach that makes it easy to drill down to a very specific element or issue. Ultimately, I find a solution and explanation that enables me to practice the concept several different ways. It has helped me from day one, and as my practical knowledge of Action Script 3 grows, it is easy to fine-tune my scripting skills with more complex, remarkably concise examples that I am able to utilize in real world situations as I learn.
ultimate, September 13 2007





This book entair very easy understanding
Annoying!, September 08 2007





Nothing bothers me more then when I pick up a book and it says something like "For a Flash solution, see additional notes at https://www.rightactionscript.com/ascb." yet there are no notes at that location. Why put it in the book at all? Annoying!
Re: Dissapointed with the Downloads, September 01 2007
Submitted by Anonymous Reader [Respond | View]
I think the helper classes are here: https://rightactionscript.com/ascb/
Dissapointed with the Downloads, August 19 2007





So I am learning quite a lot from this book. My only complain is that the downloads ZIP file with the examples does not contain the helper custom classes that the authors keep bragging about. I downloaded the examples.zip from the O'Reilly web site and the Pen class is nowhere to be found, plus the script files are all TXT files with typos everywhere. Most functions have "(())" instead of "()" after the constructor and unless you open all files in the zip file and fix them, they are useless.
Other than that, aside from the fact that the book description states that this is a book for Flash platform and Flex, most of the code is really assumed to be run on Flex Builder.
Still I have managed to make most of it work on Flash CS3 Authoring tool, but not all. So beware if you are planning to use this book to solely work on Flash CS3 Professional.
An updated zip file with corrected typos and all the helper custom classes would be greatly appreciated. Get to work authors! You are slacking off.
A light at the and of the tunnel, August 04 2007
Submitted by Anonymous Reader [Respond | View]
I consider myself as an early adopter of anything in interactive communication. I founded my company Falcomedia in 1989 with only one goal: to produce interactive multimedia communication. By then only possible on Mac's with programs like Hypercard, Supercard (in color) or Macromind's Director (called Videoworks by then). I definately see AS3 as the end of a tunnel and the start of really great things to come. It's possible now, no workarounds, pure OOP and this book is basic.
Read als Keith Peters Actionsript 3.0 Animation and let your visions flows. I can't see anything stopping us from bringing good UI, quality design, efficient production and scalability to the next generation of the web.
Peter Bohny, Falcomedia Systems AG, Switzerland
This is a "Dream Book" for ActionScript 3 Programmers!, May 16 2007





Have you ever dremt about the book.! No? You will find that such a book exists in the world. And it about AsctionScript 3 by Joey Lott, Darron Schball& Kaith Peters.
Start to read ? page by page you are going deeper and understand the core of ActionScriot3. And not only the theory of this flexible programming language but also the practice. The book is reach with example that will help you to see actions and catch them very easy. You only need to ?addEventListeners? to your ideas and implement them in real programming
This book is easily read, easily understood and shows the right way to master ActionScript. Its covers all parts of ActionScript3 programming from ?A to Z? without missing any letters.
This book is really a coockbook. A lot of easy example help you to combine them in one big project like is done in the ?Chapter 15: Programming Sound?. The same I can say about ?Chapter 11?Programming Animation?.
This book will become your Best Everyday Friend!. It will help you to find the solution of each task that you have in ActionScript4 projects.
This book isn?t about XML but you will find out that ?Chapter 20: XML.? Covering all the fibers of new E4X : what it is, why and how to use in ActionScript4. it?s written very transparent and clear.
So this is a really DREAM Book for beginners and ActionScripts programmers.
I would like to thank authors for their hard and excellent work and recommend the book to all the ones who want to became ActionScript programmer.
Ares Hovhannesyan
Adobe Certified Designer
Manager of Adobe User Group in Armenia
Versitile read, May 08 2007





Depending on the user this book can be used in different ways. The first way is to find specific answers to certain situations that may arise from everyday programming. The tables of contents are broken down into discrete sections pertaining to one aspect of AS3. If you are looking for help on string formatting a quick glance in the TOC will be a great start. In each section it is further broken down into sub-sections each addressing a particular point or "problem" that needs to be resolved. These sections are broken down into "Problem", "Solution" and "Discussion". Most sections show a short problem and solution but the meat of the text resides in the discussion portion. With the combination of code and explanation really breaks down the problem to a level most developers can understand. Additional footnotes are used to tie concepts together from section to section or "recipe to recipe". The second way to read this book is cover to cover. Even though these topics are broken down in specific problems, learning from "quasi-real world issues" are always a great way to learn. To be honest I would have also preferred a table of contents with the actually problems mentioned in each section. I saw myself having to thumb through the whole book getting acquainted with what it had to offer. If there is that link established then when I do encounter that issue my mind will remember that I read something similar in this book. My overall impression was positive and will keep this book handy for future reference.
Designers need it to.., March 31 2007





Are you a designer? You need this book. Now before you spam me, let me tell you I'm as addicted to onEnterFrame as anybody. I've been limping along, using the same loadMovie script I copied way back and in general avoiding scary words like OOP. Hell, If you asked me a year ago what Flex 2.0 was, I would've told it's an exercise machine endorsed by Chuck Norris!
But let me tell you, the changes in AS3 are fundamental, deep and life-changing. I've been inching towards using attachMovie, separate functions, etc. But AS3 takes it a step further, forcing you to get organized and import only the classes you need. Furthermore, the whole way objects are displayed has changed. No more "_root". Not even "_x". Like I said, you need this book.
Bottom line, AS3 will separate the men from the boys and this book will help you get on the bandwagon. The developers might grumble that this book spends too much time on the basics, but for those of us who need more practice than theory, this book is a good start.
Designers need it to.., March 31 2007





Are you a designer? You need this book. Now before you spam me, let me tell you I'm as addicted to onEnterFrame as anybody. I've been limping along, using the same loadMovie script I copied way back and in general avoiding scary words like OOP. Hell, If you asked me a year ago what Flex 2.0 was, I would've told it's an exercise machine endorsed by Chuck Norris!
But let me tell you, the changes in AS3 are fundamental, deep and life-changing. As a designer, it will give you more visual power with things like the Loader class and the Timer class. And remember how weird it was that every MC had it's own depths? Poof! It's gone with the new display architecture. What's the display architecture? See, I told you you were in trouble!
Bottom line, AS3 will separate the men from the boys and this book will help you get on the bandwagon. The developers might grumble that this book spends too much time on the basics, but for those of need more practice than theory, this book is a good start.
Solid intermediate reference, March 07 2007





I went through this book quite fast. Maybe because I knew the AS2 version before. It is a solid reference, I feel it fits more in the middle of skill-level. ActionScript newbies may not get enough OOP/ActionScript fundamentals to abuse this book, and more advanced AS folk may just flip through the book for kicks.
I recommend this book if you're used to writing functions and are exposing yourself to AS Classes.
Immediately Useful and a Great Read, February 14 2007





The ?ActionScript 3.0 Cookbook? was a great read. In fact, I read most of it in a local bookstore in the course of one evening. The code samples were immediately useful and easy to follow ? I have already put them to use in my current Flex 2 projects. Chapter 6 (Display List), Chapter 15 (Programming Sound), and Chapter 16 (Video) were especially useful to me. I found that looking up ActionScript-related keywords in the index allowed me to quickly get to the ?good stuff? on a particular topic. For instance, I needed some help on adding a TextInput control to a Canvas using only ActionScript (e.g. not with the MXML tag). I found ?adding item to display list, 141-145? in the index, and the detailed explanation of the solution was exactly what I needed ? no fluff, just stuff. Thank you to O?Reilly and the authors, Joey Lott, Darron Schall, and Keith Peters for the inspiration.
Needs an update, January 29 2007





It is clear that this text needs an update. There have been changes from the Flex 2 Beta to the latest version of Flex 2, and some scripts just don't work. The video player is quite troubling, and it's sad to hear that there are other problems as noted by another reviewer on this page.
What's even more upsetting is that the samples.zip available for this book contain the same errors present in the text. Consistency is good in some cases, but not in this one.
I should note that all of the resources I've found for learning AS3 have errors in them, including the materials from Lynda and TotalTraining. I mean, even the completed examples from the DVDs don't run properly, so someone needs to do clean-up on all of these resources.
O'Reilly has been good at noting changes in the past, but they seem particularly slow on this book.
In sum, unless you're already up to speed on AS3, you might want to wait before you buy any of the materials available for learning it.
Strong medicine against all those unknown unknowns, January 19 2007





As a newbie to actionscript 3 from actionscript 2 and trying to work in the flash 9 alpha environment, I was disappointed to find that the chapter on the SoundSpectrum was full of errors. Had I been a total novice I think I would have given up very quickly in trying to get this recipe to work, however with a little common sense and a quick trip online I managed to get the visuals to work, its just a shame it didnt work straight of the book. I havent read much more of the book as I have only had it few days and today was the first I've had had at trying any of the recipes. Is this only section with code erros or have I the rest of the book to enjoy with the challenge of fixing code which doent work.
A must for all User Experience Developers alike., December 11 2006





I've using FLEX since its 1.0 beta days, and can honestly say that each day I learn something new about this language. It's even better when you have the "cheat codes" for the game in which we play, FLEX development.
This book has quite comprehensive repositories of good ol fashion FLEX recipes and are relevant to the average FLEX developer out there.
It's not so much for the newbie?s, but it doesn't count them out either as it finds a nice balance in helping folks learn from Code instead of FLEX 101 lessons.
As others have hinted, the focus on DisplayLists will open a few minds to the possibilities of how easy they are and the concept of re-parenting is something that most will not be able to grasp.
I'd rate this book to be a must have for anyone using FLEX right now, and if you're a FLASH developer of old, moving into the ranks of FLEX then this has to be a first purchase.
I don't usually give glowing references like this to books, and so its rare I talk it up like I have but its a great book written by some serious propeller heads who have the respect of their peers within the FLEX "who's who".
Strong medicine against all those unknown unknowns, November 28 2006





Half our battle as Flash developers is knowing where to look for fast and accurate guidance when we need it. ?ActionScript 3.0 Cookbook, Solutions for Flash Platform and Flex Application Developers? by Joey Lott, Darron Schall and Keith Peters, is strong medicine against all those unknown unknowns.
The first part of the ActionScript 3.0 Cookbook covers programming essentials ? loops, conditionals, functions, Numbers, Strings, Arrays, Math etc. Skipping around in the book is encouraged, but don?t discount this section just because it?s focused on the basics. Tucked away as early as page 10 you?ll get your first taste of some fundamental shifts in AS3, including changes in the way onEnterFrame, Mouse and Key events are handled and the new Timer class that replaces intervals.
AS3CB comes with a pack of useful classes to use in your everyday work. Need to duplicate a multidimensional array? Save yourself the hassle (some would say fun) of writing a recursive function and just use the ?duplicate? method of the ArrayUtilities class provided with the book. Other bundled utility classes include a Pen class for drawing ellipses, triangles, polygons and arcs, and Date and Number classes for handling common numeric manipulations.
Chapter 6 pushes you into the deep end. AS3 introduces a fundamental shift in the way you put things on the stage: the Display List. The display list gets populated with Display Objects including Bitmaps, Shapes, Sprites and more.What?s a Sprite? Think of a Sprite as a MovieClip without the overhead of a timeline when you don?t need one. The new Loader class is another Display Object that works a lot like the old MovieClipLoader class for bringing external assets into your Flash projects with detailed event notification of the progress of the load.
Mouse interaction has undergone some significant changes. startDrag and stopDrag are still with us, but the AS3CB offers the DraggableSprite class for easy enhancement of mouse dragging including dragging multiple objects at once and decreased rendering lag. One of my favorite features of O?Reilly books are the ?tips and traps? ? little asides that keep you on track. One ?trap? in this chapter cautions you to remember to set the new hitTestState or your buttons won?t be clickable. A ?tip? reminds you that mouse events are generated from display objects only when the mouse is over them.
Another significant update to the language is how it handles XML. The XML chapter covers the new method for loading XML and the great new tool in AS3 for manipulating your XML objects: E4X. E4X allows you to navigate the XML tree using good ol? dot notation instead of aggravating child node references. Sending and loading data is handled differently than in AS2: loadVars is out - URLLoader is in.
Flash users now have access to Regular Expressions to search for patterns within their text. A solid 20 pages introduce the topic, explaining the power of the cryptic strings of text that make up a Regular Expression. This is a great reference to keep on hand for brewing up your own RegExes and it offers pre-baked recipes for common RegEx activities like validating user input for email, phone numbers, dates and zip codes.
Chapters on Sound and Video cover the basics (most of which haven?t changed, barring some of the more widespread changes that come with the shift to AS3). One standout, however, is the new computeSpectrum method of the Sound object that allows you to turn a sound wave into data that can be used for visualization ? now we can make graphic equalizers that actually represent the sound wave. computeSpectrum gets a snappy 2-page recipe to get you up-and-running with your own functional example to expand upon.
Even if you don?t read AS3CB from cover-to-cover, it?s worth giving it a once-over so you know what challenges you will face and can overcome when the time comes. As we know, there are known knowns; there are things we know we know. We also know there are known unknowns; that is to say we know there are some things we do not know. But there are also unknown unknowns -- the ones we don't know we don't know. Don?t be a developer who doesn?t know what you don?t know.
---
Elliot Mebane is a Los Angeles Flash Application developer with a focus on Flash Video Applications and Game development. Visit www.roguish.com for more information.
ActionScript 3.0 Cookbook, November 17 2006





ActionScript 3.0 Cookbook
Authors: Joey Lott, Darron Schall, Keith Peters
Published: October, 2006
Publisher: O'Reilly Media, Inc. (https://www.oreilly.com/catalog/actscpt3ckbk/index.html)
ISBN: 0-596-52695-4
Pages: 562
Reviewed November 17, 2006
by Kirk Holbrook, Manager
Maine Flash Platform User Group
This is an excellent book. I'd recommend it to anyone using Flex 2 (and eventually Flash 9) -- especially now with the limited resources available for ActionScript 3 (AS3). There are a lot of useful examples along with coherent explanations of why the authors are programming the way they are.
The chapter on XML (chapter 20) is a must-read. It includes concise summaries of dealing with XML in AS3, which has changed significantly from AS2. Generally, XML handling is much easier in AS3, but there are some areas that can be really confusing when making the switch from AS2. This book explains most things you'll need to do with XML in AS3.
The chapter titled "Display List" (chapter 6) also contains critical information for developers coming from AS2. The rendering model in Flash Player 9 is completely re-designed -- a move away from the
MovieClip
class (although it's still in there) to the new DisplayObject
class. The examples provided here give some important guidance on working with the various elements in rendering your project's interface.I particularly like some of the custom classes available as a free download (of course, you should buy the book for those!). For instance, recursive arrays can be a hassle to deal with, but very useful in many projects. One of the classes includes several Array utilities -- one, in particular, that makes dealing with recursive arrays easier.
Of course, there's a lot of other great stuff in this book. I won't touch on all its greatness, but, again, I do recommend it highly.
That said, I do have a few complaints.They are not to dissuade you from buying the book, but to give the authors some feedback, in hopes that they can improve the next edition.
The authors state that this book is not intended to be an introduction to AS3. However, since it's really the first book to market on AS3, I'm sure that many AS3 developers will be looking to it for some introductory material.
The first 60 pages also seem to reinforce this impression. There are many pages devoted to basics of AS3, like creating functions and classes. Forcing these into the Cookbook scheme seems rather trite in several instances. Take, for instance, 2.5 Creating Subclasses. The Problem is stated as "You want to create a class that inherits from an existing class." And the Solution is "Write a subclass using the extends keyword." Now, if I know I want to create a class that inherits from another class, I'm pretty well along the way to knowing that I want to extend the latter. And I can probably find the answer much more readily in the Flex 2 or Flash 9 documentation. I'd rather see an appendix with documentation on the free-to-download custom classes, than 60 pages of very basic AS3.
In the interest of full disclosure, let me say that I have not read any of the Cookbook developer books lately, so some of my remarks may be a bit off base here. But it seems to me that this title falls short of the idea that I have for a Cookbook. There are a lot of good tidbits in here, like creating custom buttons and the inclusion of several custom class files, such as the already mentioned
ArrayUtilities
class (along with several other useful utilities classes) and the Cards
class. But most of the Problems and Solutions are more like ingredients than recipes.If I were editor of a book like this, I'd aim for more advanced Problems and Solutions that combine the various ingredients to provide a richer set of problems solved. How about solving the following Problems:
- I want to create a tile based game. How can I work with various sized grids to create a seamless experience for the user?
- I have tons of UI to place in the limits of the users' screens. What are the various ways I can maximize the user experience (view stacks, tabs, and other new containers and navigator classes in AS3)?
- I want to program card games using the
Cards
class. How would I program a version of Blackjack? - I need a reliable and reusable way to hit several web services. What's a good way to split up my code into one or more classes to make this efficient?
Perhaps the Cookbook I'm describing better fits the Hacks series from O'Reilly. Or maybe it's more of an Advanced Cookbook.
But, yes, it's extremely useful. If you're using Flex 2, or plan to use Flash 9, run out and buy a copy -- now!
Media reviews
"You won't be surprised with this book... it is up to par with the other resource rich Cookbooks we know and love from O'Reilly. "
-- James R. Hicks, Amazon review
"The book is focused on solution to a specfic problem and specfic task. Also the solutions covered are very well explained with good examples. This book is not a Actionscript Programming Guide. E4X support is very well explained. "
-- Amazon reviewer
"Written to support Adobe Flash platform and Adobe Flex application developers in their quest for more speed and power, this includes over 300 recipes and a host of nuts-and-bolts information. The authors, all master practitioners, begin with the basics, such as where to place code and how to handle events, then move on to creating and determining a custom class and subclasses, working in the runtime environment, including detecting the player version and operating system and dealing with system security, building in numbers and math from simple arithmetic to multiple calculations, adding elements to arrays and display lists and manipulating the results, drawing and masking geometric forms, filling and scripting masks, handling bitmaps and texts, including manipulating features and formatting, using filters and transforms, programming animation, making the most of strings, using regular expressions and setting dates and times, programming sound and video, storing persistent data, communicating with other movies, sending and loading data, using XML, calling web service methods, building integrated applications, managing files and programming sockets. The results should keep everyone from novices to advanced users on track."
-- Jane Erskine, Book News Inc.
Read all reviews

- Table of Contents
- Index
- Sample Chapter
- Examples
- Register Your Book
- View/Submit Errata
- View/Submit Review
Got a Question?
![]() © 2009, O'Reilly Media, Inc. (707) 827-7000 / (800) 998-9938 All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners. |
About O'Reilly Privacy Policy Contacts Customer Service Authors Press Room Jobs User Groups Academic Solutions Newsletters Writing for O'Reilly RSS Feeds Terms of Service |
Other O'Reilly Sites O'Reilly Radar Ignite Tools of Change for Publishing Digital Media Inside iPhone O'Reilly FYI makezine.com craftzine.com hackszine.com perl.com xml.com |
Sponsored Sites Inside Aperture Inside Lightroom Inside Port 25 InsideRIA java.net |