Components: A Scripting Primer


Because the focus of this book is ActionScript, our discussion in this lesson largely centers on how to work with and use Flash components from a scripting standpoint. For a more thorough overview of components, consult the documentation that comes with Flash.

A component is usually nothing more than a movie clip with some built-in functionality. Components can be customized using ActionScript in two ways:

  • You add components to a project manually by dragging them onto the stage within Flash's authoring environment, via the Property Inspector or Component Inspector.

  • You add components to a project dynamically using ActionScript while the movie plays.

When a component is added by either technique, you're actually placing an instance of that component type/class into your project. For example, if you drag and drop a CheckBox component onto the stage in the authoring environment, that object is considered to be a CheckBox component instance. As when using other object instances, you assign names to component instances; the instance name can be used in your scripts to communicate with that component instance.

graphics/10inf02.gif

A number of user interface components ship with Flash. These components allow you to create forms and menus, or to display information and visual content in interactive ways.

Flash also ships with data components and media components. Data components provide a relatively easy way of working with the data in your application, especially sending and retrieving external data. Media components enable you to display and control the playback of media elements such as video and MP3 files. The primary focus of this lesson involves using and working with user interface components. You'll learn about media element component types in later lessons.

As you learn throughout this lesson, most components share some common functionalities and capabilities. As a result, the common ActionScript syntax works in the same way no matter what component instance you're scripting. At the same time, each type of component is built to be used for a specific purpose; thus, each type of component has some unique ActionScript commands.

Using ActionScript, you can do any of the following:

  • Configure a component instance while your movie plays

  • Tell the component instance to react to a specific event

  • Retrieve data from a component instance

  • Change the appearance of a component instance

In the exercises in this lesson, you'll implement each of these types of interactivity in the creation of a URL manager, which is used as a mini-database for Web, FTP, and email addresses. The result will be a highly interactive application, requiring relatively little scripting to make it work.



Macromedia Flash MX 2004 ActionScript(c) Training from the Source
Macromedia Flash MX 2004 ActionScript: Training from the Source
ISBN: 0321213432
EAN: 2147483647
Year: 2005
Pages: 182

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net