Previous Section Table of Contents Next Section

Hack 64 Dude, Where's My Scrollbar?

figs/beginner.gif figs/hack64.gif

Create a lightweight scrollbar component for Flash MX 2004.

The v2 components that ship with Flash MX 2004 are geared toward creating complex user interfaces and Rich Internet Applications. The v2 components offer several enhancements over the v1 components, including support for depth management, keyboard focus management, and accessibility. The v2 components are completely rewritten to work in ActionScript 2.0 (including strict datatyping and case sensitivity). The v2 components also share a new component framework designed to optimize filesizes when you use five or more components in a single SWF (as Macromedia's research found to be typical).

However, the Flash MX 2004 components can't be used as simple drop-in replacements for the Flash MX v1 components for several reasons:

  • The first v2 component included in a SWF requires a 30 KB download to set up the initial classes for the component framework. To be fair, additional components cause only a small increase in download size, thanks to the common framework shared by all v2 components.

  • The v2 components for Flash MX 2004 don't include a standalone scrollbar (although the 7.2 update is expected to include one).

And you can't simply use the old v1 components that ship with Flash MX if you export your SWF in Flash Player 7 format, because the old components don't conform to Flash Player 7's case-sensitivity requirements as discussed at http://swfoo.com/archives/000034.html. Even if you update a Flash MX (Flash Player 6) FLA file into Flash MX 2004 (Flash Player 7) format, including making your scripts case-sensitive, the code associated with the v1 components still may not work due to case and type casting inconsistencies within the components themselves and differences in the behavior of some built-in ActionScript functions in Flash Player 6 and 7. The workaround is to use the updated "Flash MX components for Flash MX 2004", as described next.

Although many third-party components, including scrollbars, are available, it would be nice to use Macromedia components to ensure compatibility with future versions of the Flash Player (Macromedia makes a serious effort to ensure that older SWFs run unmodified in newer versions of the Flash Player).

The v1 components from Flash MX included a standalone scrollbar and can be used in Flash MX 2004 when exporting your SWF in Flash Player 6 format (although you should avoid mixing v1 and v2 components in the same project). Flash Player 7-compatible versions of the v1 components, which are not as bandwidth-heavy as the v2 components, are available from the Flash Exchange (http://www.macromedia.com/exchange/flash), in the User Interface category, under the title "Flash MX Components for Flash MX 2004."

You can also access the Flash Exchange via Flash's HelpFlash Exchange option. The v1 components are distributed as an .mxp file. To install them, you must have installed the Macromedia Extension Manager, which is also available online at the Flash Exchange.

Once installed correctly, you will see the updated Flash MX components appear in the Flash MX 2004 Components panel, under Flash MX UI Components as shown in Figure 8-11. The Flash MX 2004 components are kept safely separate under UI Components in the Components panel.

Figure 8-11. The Flash MX UI components in the Flash MX 2004 Components panel
figs/flhk_0811.gif


The Flash MX components don't have all the sexy features of the Flash MX 2004 components. However, if the only component you need is a scrollbar for a text field or other slider control, as shown in Figure 8-12, you can simply drag the Flash MX UI scrollbar from the Components panel and drop it onto the Stage just as you did back in Flash MX. It will work even if you have the publishing options set to the Flash Player 7 and ActionScript 2.0. Best of all, the Flash MX scrollbar adds only 6 KB to the SWF filesize.

Figure 8-12. Using the Scrollbar component
figs/flhk_0812.gif


Final Thoughts

Progress is great, and the Flash MX 2004 v2 components offer many advanced features such as focus management, depth management, and accessibility, but sometimes you just want one freakin' scrollbar!

If that's the case (and especially if 30 KB for one component is out of the question), you can use the solid and familiar Flash MX scrollbar from the v1 component set to meet your needs.

    Previous Section Table of Contents Next Section