More and Better Components

     

More and Better Components

Components are self-contained, portable building blocks for applications. Components make it easy for programmers to deliver internally complex functionality in an easy-to-use modular form. They implement functions that you use over and over again in many applications. Rather than build the functionality from scratch each time, you can just drag and drop a component onto the Stage, perhaps customize the component's appearance, and set a few parameters. Using components also helps you maintain consistency within an application.

Flash MX shipped with 7 components. Flash MX 2004 ships with 13. Flash MX 2004 Professional comes with 30 components!

In addition, Flash MX 2004 introduces a new generation (V2) of faster-loading, better-behaved components:

  • Faster-loading . The V2 components initialize and resize more quickly than the V1 components that came with Flash MX, so the user sees the first screen of the application more quickly, and the components feel more responsive . They're also faster to work with in the authoring environment.

  • Better-behaved . The V1 components sometimes had problems managing behaviors such as depth (whether an object is "in front of" or "behind" other objects) and focus (whether an object is selected or not). For instance, after you tabbed into a component, it was sometimes impossible to tab out of it. Now there are non-visual, automatically loaded components called managers to help address such problems. The managers are FocusManager, DepthManager, PopUpManager, and StyleManager.

In the V2 component architecture, components are compiled, so you can't get at their source code through the component itself, whether to modify the component or learn from it. Macromedia, however, has included the source code separately for the standard components (though not the Flash Pro data components) as part of the Flash MX 2004 install.

For a link to information on the location of the source code for components, see componentSource.htm on the CD accompanying this book.


Unfortunately, it's not advisable to use V2 and V1 components in the same application. V1 components are supported in Macromedia Flash MX 2004, but you have to publish to a version 6 SWF file when you use Actionscript 1.0. So, porting existing component-based applications into Flash MX 2004 can be a bit of a pain. More so because Macromedia neglected to make a V2 version of the V1 Scrollbar component. A scrollbar is part of the ScrollPane component, as well as the new TextArea component, so you still have scrollbars where you most need them when building applications from scratch. (The recommended solution for creating scrolling text in Flash MX 2004 is to use the TextArea component.)

The standard version of Flash MX 2004 has 13 user interface (UI) components ”visible controls such as RadioButton, CheckBox, and TextInput that enable a user to interact with an application. In addition to 21 UI components, Professional has 3 media components (UI controls for displaying and controlling playback of FLV and MP3 files) and six non-displaying data components (for accessing Web Services and XML data sources).

The first V2 component you drop on the Stage includes about 25KB of standard infrastructure, which can be shared by all subsequent components. That 25KB is a heavy price to pay if you use just one or two components. Spread over a dozen components, it becomes negligible. Still, user interface controls custom-designed for a particular application will always be lighter weight than general-purpose components.

For more on using components, see "Accelerating Application Development with Components," page 426 in Chapter 18.




Using Macromedia Studio MX 2004
Special Edition Using Macromedia Studio MX 2004
ISBN: 0789730421
EAN: 2147483647
Year: N/A
Pages: 339

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