Foundation ActionScript 3, Second Edition

Book description

ActionScript 3 is a full-fledged programming language, with complete object-oriented capabilities, event handling, sound and video support, drawing capabilities, support for regular expressions, and much more.

Whether you are just starting out on the road to computer programming and animation or an experienced developer who wants to learn a new language, you’ll find all you need to know in Foundation ActionScript 3.

Starting with the fundamentals, you’ll learn how to add interactivity to your Flash movies by using ActionScript objects, manipulating sound and video, and harnessing the power of regular expressions and XML. The book concludes with two case studies to consolidate what you’ve learned and introduce some additional advanced techniques. You’ll gain a solid understanding of the exciting world of ActionScript 3 and see how everything fits together, so you’ll be able to build your own professional applications.

The sensible layout of the book makes it easy to find information about specific techniques. It focuses on the essential skills that will enable you to get up and running quickly. With this book as your guide, you’ll be creating killer Flash applications before you know it.

Table of contents

  1. Cover
  2. Title
  3. Copyright
  4. Contents at a Glance
  5. Contents
  6. About the Authors
  7. About the Technical Reviewer
  8. Layout Conventions
  9. Chapter 1: Getting Started with ActionScript 3.0
    1. A Brief History of ActionScript
    2. The Rise of ActionScript 3.0
    3. ActionScript and Object-Oriented Programming
    4. The Development Process
    5. Organizing Your Files
    6. Adding ActionScript to Your Projects
      1. Placing Code on the Timeline
      2. Importing Code from an External File
      3. Specifying a Document Class
      4. Linking Library Assets to External Classes
    7. Bouncing Balls
      1. Creating the Flash File
      2. Creating the Ball Class
      3. Adding More Balls
    8. ActionScript in Action
    9. Summary
  10. Chapter 2: ActionScript 3.0 Fundamentals
    1. Statements and Expressions
    2. Introducing Variables
      1. Assigning a Value to a Variable
      2. Retrieving the Value of a Variable
      3. Naming Your Variables
      4. Understanding Data Types
    3. Using Constants
    4. Performing Operations
      1. Arithmetic Operators
      2. Specifying Precedence
      3. String Operations
      4. Unary Operations
    5. Introducing Arrays
      1. Manipulating Arrays
    6. Vectors vs Arrays
      1. Understanding Type Checking
    7. Making Decisions
      1. Introducing the if Statement
      2. Forming Boolean Expressions
      3. Booleans in Conditionals
      4. Using Logical Operators
    8. Looping the Loop
      1. The while loop
      2. The do . . . while loop
      3. The for Loop
      4. Looping through an Array
      5. More for Loops
      6. Breaking Out of a Loop
      7. Looping through a Vector
    9. Introducing Functions
      1. Creating a Function
      2. Returning a Value from a Function
      3. Using Function Parameters
      4. Providing a Default Value for Function Parameters
      5. Allowing for Variable Parameters
      6. Passing Values and References
      7. Function Scope
    10. Commenting Your Code
      1. Bad vs. Good Comments
      2. Commenting for Documentation
    11. Summary
  11. Chapter 3: Objects and Classes
    1. iPod Analogy
    2. Working with Objects
      1. Creating Objects using the New Operator
      2. Accessing Properties and Calling Methods
      3. Copying Objects
      4. Casting Objects to a Type
      5. The Object Object
      6. Iterating Over Objects
      7. Dictionaries vs Objects
      8. Native JSON
    3. Creating Your First Class
      1. Choosing Suitable Names for your Classes
    4. Adding Properties
    5. Adding Methods
      1. Initializing Your Objects with a Constructor Method
    6. Controlling Access to Properties and Methods
    7. Adding Getter/Setter Methods
      1. Creating Read-Only Properties with Getter Methods
    8. Static Properties and Methods
    9. Taking Advantage of Inheritance
      1. Overriding Methods of the Base Class
    10. Using Packages to Group Your Classes
      1. Naming Your Packages
      2. Importing a Class from a Package
      3. Importing all Classes in a Given Package
      4. Resolving Naming Conflicts among Imported Classes
    11. Removing Dependency on Timeline Code
    12. Summary
  12. Chapter 4: Working with the Display
    1. Introducing the Display List
    2. Working with Display Objects
      1. Manipulating Display Objects
      2. Managing Depth
      3. Creating new Display Objects
      4. Removing Display Objects from the Display List
    3. Specifying Bl Modes
    4. Working with Filters
      1. Applying a Filter to a Display Object
      2. Applying Filters in a Specific Order
      3. Making Changes to an Existing Filter
      4. Removing an Existing Filter
      5. Introducing the Advanced Filters
    5. Accessing the Stage
      1. Using Stage Properties
      2. Making a Movie Full Screen
    6. Using Library Resources
    7. Loading from External Files
      1. Loading an External Asset
      2. Manipulating the Loaded Asset
    8. Making Things Move
      1. Copying Animation from the Timeline
      2. Animating other Properties
    9. Summary
  13. Chapter 5: Creating Vector Graphics with the Drawing API
    1. Why we Need a Drawing API
    2. Understanding the Drawing API
    3. Setting up Mr. Smiley
    4. Drawing Lines
      1. Creating Straight Lines
      2. Controlling the Line Style
      3. Drawing Curved Lines
    5. Drawing and Filling Shapes
      1. Drawing Primitive Shapes
      2. Creating Custom Shapes
      3. Filling Shapes with a Solid Color
      4. Filling Shapes with Color Gradients
    6. Simplifying the Code
    7. Creating Gradient line Styles
    8. Flash 3D
    9. Summary
  14. Chapter 6: User Interaction and More with Events
    1. Understanding Events
      1. Listening for an Event
      2. Removing an Event Listener
      3. Naming Your Event Listener Methods
      4. Creating a Simple Drawing Application
      5. Using One Event Listener for Multiple Objects
    2. Using Events with the Display List
      1. Handling Single and Double Mouse Clicks
      2. Handling Mouse Hover States
      3. Handling Key Presses
      4. Preventing an Event’s Default Action
    3. Capturing and Bubbling: The Event Flow
      1. Listening for Events in the Bubble Phase
      2. Listening for Events in the Capture Phase
      3. Stopping an Event from Propagating
      4. Removing Capture Phase Event Listeners
    4. Summary
  15. Chapter 7: Working with Video
    1. Video on the Modern Web
      1. The Video Experience
      2. Where ActionScript Comes in
    2. Encoding Your Video
      1. Capturing Your Video
      2. Using the Flash Video Encoder
    3. Delivering Your Video
    4. Using ActionScript to Play Videos
      1. Managing Connections with the NetConnection Class
      2. Loading and Controlling Video with the NetStream Class
      3. Creating Video Objects with the Video Class
      4. Creating Camera Objects with the Camera Class
      5. Handling Video Events
    5. Building a Video Player
      1. Setting up the Project
      2. Controlling the Video Player
      3. Controlling the Video on the Stage
      4. Creating a Custom Event
    6. Summary
  16. Chapter 8: Using Audio
    1. Importing and Converting Sound Files
      1. Using iTunes
      2. Using Adobe Audition
    2. Using ActionScript to Play Sound
      1. Accessing Sound Files with the Sound Class
      2. Controlling Sound Channels with the SoundChannel Class
      3. Doing Security Checks with the SoundLoaderContext Class
      4. Controlling Volume and Panning with the SoundTransform Class
      5. Controlling Sounds Globally with the SoundMixer Class
      6. Getting ID3 Data with the ID3Info Class
      7. Using a Microphone with the Microphone Class
      8. Understanding the Basics of a Sound Player Application
    3. Building a Sound Player
      1. Setting up the Project
      2. Adding Display Items
      3. Controlling the Audio as it Plays
      4. Controlling the Sound Volume and Panning
      5. Creating the Custom Event Class
    4. Summary
  17. Chapter 9: Working with Components
    1. Just What are Components?
      1. Accessing Your Components
      2. Adjusting Component Parameters
    2. Benefits of Working with Components
    3. Exploring the Flash Component Framework
      1. UI Components
      2. Video Components
      3. Going Behind the Scenes
      4. Finding the Files
    4. Scripting Interaction
      1. Adding the Components
      2. Adding the ActionScript
    5. Styling and Skinning
      1. Styling Components
      2. Skinning using the Timeline
      3. Skinning using Classes
    6. Creating Components from Scratch
      1. Creating the Widget
      2. Writing the Component Code
      3. Turning the Symbol into a Component
      4. Testing the Component
    7. Using Third-Party Components
    8. Summary
  18. Chapter 10: Regular Expressions
    1. Why you Need Regular Expressions
    2. Introducing the RegExp Class
    3. Anatomy of a Regular Expression Pattern
      1. Introducing Metacharacters
      2. Providing Alternatives with Alternation
      3. Using Character Classes and Character Ranges
      4. Matching any Character using the Dot Metacharacter
      5. Matching a Number of Occurrences Using Quantifiers
      6. Grouping Patterns
      7. Accessing Matched Strings with Backreferences
    4. Understanding the E-Mail Regular Expression-­Pattern
    5. Changing Regular Expression Behavior with-­Modifiers
      1. Using the Case-Insensitive Modifier
      2. Using the Global Modifier
      3. Using the Multiline Modifier
      4. Using the Dotall Modifier
      5. Using the Extended Modifier
    6. Using Variables to Build a Regular Expression
    7. Useful Regular Expressions
    8. Regular Expression Resources
    9. Summary
  19. Chapter 11: Using XML
    1. Understanding XML and E4X
      1. XML Document Components
      2. E4X
    2. Accessing an XML File
      1. Creating an XML Object
      2. Loading an XML File
      3. Getting XML from a Remote Source
    3. Reading the XML
      1. Reading the Root Node
      2. Reading Elements in an XML Tree
      3. Reading an XML Element’s Attributes
    4. Searching XML
      1. Searching for an Attribute or Element at any Level
      2. Reading Text Nodes
    5. Modifying XML
      1. Adding Elements to an XML Object
      2. Removing Elements and Attributes from an XML Object
    6. Summary
  20. Chapter 12: Case Study: Creating a Dynamic Image Viewer
    1. An Overview of the Image Viewer
    2. Laying out the Interface
    3. Creating the Document Class
    4. Loading Image Data
      1. Loading the XML
      2. Parsing the Data
      3. Accessing the Data
    5. Displaying Images
      1. Handling Image Selection
      2. Scaling an Image
    6. Adding Graphic Enhancements
      1. Changing the Image Label
      2. Improving the Thumbnail Layout
      3. Adding Drop Shadows
      4. Creating an Animated Transition
    7. Summary
  21. Chapter 13: Getting Started with Flex
    1. Introducing Flex
    2. Understanding Rich Internet Applications
    3. Meet the (Flex) Family
      1. The Flex Framework
      2. The Flash Player
      3. MXML
      4. The Flex Software Development Kit
      5. Flash Builder
      6. Adobe LiveCycle DS
      7. Adobe AIR
    4. Getting Started with the Flex SDK
      1. Installing the Flex SDK
      2. Finding a Suitable Editor
      3. Building your first Flex Application
    5. Getting Started with Flash Builder
      1. Understanding the Flash Builder Interface
      2. Building your first Flash Builder Application
    6. Summary
  22. Chapter 14: Flex by Example
    1. Planning the Application
      1. Gathering the Requirements
      2. Creating the Functional Specification
      3. Designing the UI
      4. Designing the Interaction
      5. Designing the Data and Logic
    2. Setting up the Project
    3. Creating the Basic UI
      1. Creating the Containers
    4. Creating Basic Feed Integration
      1. Installing the XML Syndication Library
    5. Creating the Subscription Class
      1. Adding a New Class to Your Project
      2. Fleshing out the Subscription Class
      3. Testing the Subscription Class
      4. Loading the Data
      5. Allowing Subscription Instances to be used for Data Binding
      6. Creating the Subscriptions List
      7. Creating the Articles Data Grid
      8. Populating the Article Panel
    6. Completing the Subscriptions Panel
      1. Allowing Users to Subscribe to a Feed
      2. Allowing Users to Unsubscribe from a Feed
      3. Saving the Subscriptions List Between Sessions
      4. Refreshing the Subscriptions List
    7. Completing the Articles and Article Panels
      1. Finishing the Articles Panel
      2. Finishing the Article Panel
    8. Improving the Feed Reader
    9. Summary
  23. Index

Product information

  • Title: Foundation ActionScript 3, Second Edition
  • Author(s):
  • Release date: December 2014
  • Publisher(s): Apress
  • ISBN: 9781484205839