Chapter 5. Creating and Working with Code
Chapter 2 introduced the idea that ActionScript can be associated with a FLA file in more ways than one. Your approach is typically contingent on the complexity of a project and the manner in which certain visual effects are achieved. For example, you might be involved in a project that contains numerous timeline animations—think in terms of an interactive corporate mascot, whose responsiveness depends on a collection of canned manual tweens. This may require at least some code in selected keyframes of the animated timeline(s) in question. On the other hand, your project might consist of nothing more than a custom video player, in which case every asset could appear inside a single frame, and possibly be generated entirely with code. In this latter case, most or all of your ActionScript might be stored outside the authoring tool altogether.
In a nutshell, ActionScript 3.0 code can be placed in:
Keyframes of a movie clip timeline, often the main timeline
External code snippets, which are external text files with an .as extension, formatted just like keyframe code and brought into a timeline with the
include
directiveCustom classes, which are also external text files with an .as extension, but structured with the
package
definition andclass
definition keywords and referenced by a timeline with theimport
directive
In ActionScript 2.0, you could also attach code directly to objects—not just to keyframes, but to the “surface” of movie clip symbols, ...
Get The ActionScript 3.0 Quick Reference Guide now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.