Preface
This tutorial teaches both ActionScript's fundamentals and its advanced usage. Over the next 675 meaty pages, we'll be exploring every detail of the ActionScript language -- from the basics of variables and movie clip control to advanced topics such as objects and classes, server communication, and XML. By the end, we'll have covered everything there is to know about Flash developing.
This tutorial is not just for developers. The text moves pretty quickly, but a prior knowledge of developing is not required to read it. All you need is experience with the non-ActionScript aspects of Flash and an eagerness to learn. Of course, if you are already a developer, so much the better; you'll be applying your code-junkie skills to ActionScript in no time.
This tutorial fully documents the material that may be undocumented or underdocumented by Macromedia or by other third-party tutorials. Flash is notorious for word-of-mouth techniques and esoteric features. How are layers, movie clips, and loaded movies stacked in the Player? (See "Movie Clips".) What governs the execution order of code on any given frame? (See "Movie Clips".) Do event handlers have a local scope? (See "Events and Event Handlers".) Why does the number 90 sometimes show up as 89.9999999997? (See "Primitive Datatypes".) It has been my particular goal to chart these unknown waters. Of course, I also cover the basic developing techniques required in any language, such as how to make a segment of code execute repeatedly. (See "Loop Statements".)
This tutorial is designed to be kept on your desk, not to wallow away its life on your shelf. Part III, "Language Reference", exhaustively covers every object, class, property, method, and event handler in ActionScript. You'll use it regularly to learn new things and remind yourself of the things you always forget.
Above all, this tutorial is a Definitive Guide. It's the product of years of research, thousands of emails to Macromedia employees, and feedback from users of all levels. I hope that it is self-evident that I've suffused the tutorial with both my intense passion for the subject and the painfully won real-world experience from which you can benefit immediately. It covers ActionScript with exhaustive authority and -- thanks to a technical review by Gary Grossman, the creator of ActionScript -- with unparalleled accuracy.
What Can ActionScript Do?
Frankly, there's no practical limit to what a full-fledged language like Flash 5 ActionScript can achieve. Let's take a look at some of ActionScript's specific capabilities to offer a taste of the topics we'll cover throughout the tutorial. Begin thinking about how you can combine these techniques to accomplish your particular goals.
Timeline Control
Flash movies are composed of frames residing in a linear sequence called the timeline. Using ActionScript, we can control the playback of a movie's timeline, play segments of a movie, display a particular frame, halt a movie's playback, loop animations, and synchronize animated content.
Interactivity
Flash movies can accept and respond to user input. Using ActionScript, we can create interactive elements such as:
- Buttons that react to mouseclicks (e.g., a classic navigation button)
- Content that animates based on mouse movements (e.g., a mouse trailer)
- Objects that can be moved via the mouse or keyboard (e.g., a car in a driving game)
- Text fields that allow users to supply input to a movie (e.g., a fill-in form)
Visual and Audio Content Control
ActionScript can be used to examine or modify the properties of the audio and visual content in a movie. We may, for example, change an object's color and location, reduce a sound's volume, or set the font face of a text block. We may also modify these properties repeatedly over time to produce unique behaviors such as physics-based motion and collision detection.
Programmatic Content Generation
Using ActionScript, we can generate visual and audio content directly from a movie's Library or by duplicating existing content on the Stage. Programmatically generated content may serve as a strictly static element, such as a random visual pattern, or as an interactive element, such as an enemy spaceship in a video game or an option in a pull-down menu.
Server Communication
ActionScript provides a wide variety of tools for sending information to and receiving information from a server. The following applications all involve server communication:
- Link to a web page
- Guest tutorial
- Chat application
- Multiplayer networked game
- E-commerce transaction
- Personalized site involving user registration and login
These examples, of course, offer only a limited account of potential ActionScript applications. The goal of this tutorial is to give you the fundamental skills to explore the myriad other possibilities on your own. This is not a recipe tutorial -- it's a lesson in cooking code from scratch. What's on the menu is up to you.