Packaging Components as Smart Clips
A Smart Clip is a movie clip that allows some of its variables to be assigned through a special graphical user interface in the Flash authoring tool. Smart Clips allow non-programmers to customize programmatically-controlled movie clips. Smart Clips separate the behavior-determining variables from the code of a clip, which lets people treat them as “black boxes”—their operation can remain mysterious as long as their inputs, outputs, and behavior are known.
Normally, variable initialization occurs in the source code of a movie clip. For example, here we set up the variables used to control a fireworks effect:
// User-defined variables var numSparks = 10; // Number of spark clips in the explosion var randomDispersion = true; // Explosion style (true for random, // false for uniform) var duration = 1300; // Length of explosion, in milliseconds
Modifying source code of this sort can be intimidating for non-programmers. But if we build our system as a Smart Clip, non-programmers can configure the fireworks effect through a familiar application-style interface. Figure 16.2 shows a Smart Clip interface equivalent to our variable-initialization code.
Figure 16-2. A sample Smart Clip -configuration interface
In a Smart Clip interface, each variable appears with its name and value clearly distinguished in separate rows and columns. Variable names cannot be ...
Get ActionScript: The Definitive 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.