O'Reilly logo

Agile Enterprise Application Development with Flex by Tony Hillerson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Paying Tribute to Libraries

If you need to modularize reusable components, look no further than libraries: Runtime Shared Libraries (RSL), to be specific. Assuming that you are using Flash Builder, the basic procedure is:

  1. Create a Flex Library project containing classes to be reused (call it, say, ComponentLibrary).

  2. Add a mapping to this project to the Flex Build Path of the application(s) that makes use of the library classes.

If you do not have the source code, add a mapping to the SWC file of the library compiled by a third party instead of to the library project. Look in the Flex Build Path of your application: all Flex framework classes are added via several .swc files, similar to Figure 7-8.

Default link type: merge into code

Figure 7-8. Default link type: merge into code

At this configuration level, library projects merely separate development of the business application from building of the reusable components; however, your application is still built as monolithic .swf. Why? Because when you add mapping to the library project or .swc of the compiled library, the default link type is “Merged into code.” This is static linking, where the application .swf contains only those classes it could determine as required at compile time. Recall the dynamic instantiation from Example 7-19:

var clazz:Class =
   loaderInfo.applicationDomain.getDefinition("CustomGrid") as Class;
dg  = DataGrid(new clazz());

Assuming the CustomGrid ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required