V2 Components

[ LiB ]  

V2 Components

The components that ship with Flash MX 2004 are called V2 for version 2. (In fact, they started life as "smart clips" in Flash 5so one could argue they're really V3.) Every time they get better. And, every time there's a new set of usage rules. Before getting into advanced topics or details of any specific components, it's important to consider the general advantages of V2 components.

The advantages range from practical usage benefits to under-the-hood optimizations. In use, they're nicer because nearly every property is accessible using standard dot syntax. Whereas before you might have said myList.setSelectedIndex(1) , now you can just say myList.selectedIndex=1 . Not only is this more logical, it also means that you don't need a separate method for getting as well as setting. Check out how long this old way of increasing the selected index value is:


Using the new direct property access, it's just as follows :


When you attempt to explore the code behind these components, you'll quickly realize they're compiled. That is, you can't edit the code. The main idea behind compiling is to prevent users from accidentally messing up the code. You'll find the compiled SWC files inside the Components folder. (That's located in the First Run folder adjacent to Flash MX 2004.) This is also where you can install old components (which involves moving FLA files into that folder or letting the free Macromedia Extension Manager do it for you).

If you're using Flash MX Professional 2004, you can use the new components to take advantage of the new validation and formatting controls (for example, to confirm a user enters a qualified phone number). In addition, there's the whole concept of binding values from one component to another (covered in Chapter 7, "Exchanging Data with Outside Services") that's available in V2 components.

Although V2 components may be the best thing since V1 components, there are a couple of disadvantages. Most notably, file size. Adding just one button in an app that has no other components adds about 74K to the SWF's file size. This is relatively huge. However, the good news is that you can add several more components, and the size only grows marginally. That's because one component may include a variety of connected class files that make up its underlying framework.

That framework is shared among several componentsso it's not like each new component adds another 74K.


Class-Based Means Code Is Exposed and Extensible

You may think the primary reason behind compiling is securing the component programmer's intellectual property. In fact, SWC files are not exactly hack-proof. In addition, the new class-based structure makes V2 components easier to extend. That is, the code behind Flash UI components is all exposed through AS class files located in First Run\Classes\mx\controls. Don't edit those files, butif you really need tolearn how you can extend them. You can create a new class file that either overrides current methods or adds new methods to the component, and then import that into your Flash movie. Chapter 13, "Building a Code Library," touches on this subject. (Incidentally, the components in this chapter will be extended, but just not via the class files.)

Another disadvantage is the investment you make learning the "new way." Of course, this applies only if you're familiar with V1 components (in which case, try to forget much of what you know). Given the choice between Macromedia coming out with a better way every 18 months or having them stagnate so that I don't have to learn anything, I would much rather have the new stuff. Besides, in the case of V2 components, the investment in learning is paid back in productivity. Also, the rest of this chapter will give you a good start.

[ LiB ]  

Macromedia Flash MX 2004 for Rich Internet Applications
Macromedia Flash MX 2004 for Rich Internet Applications
ISBN: 0735713669
EAN: 2147483647
Year: 2002
Pages: 120

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