Flex Linkage – Difference between RSL and External

In my last post about Working With Flex Library Projects, I’ve wrote about the importance of dividing your project into different library so you could share common elements between different applications or modules.

Today I wanna talk about the different types of linkage options you have when linking an external library project or swc to your flex project / library.

As you know or may not know, you have 3 different linkage types in flex:

  • Merged Into Code
  • External
  • RSL (Runtime Shared Library)

So, what is the difference?

While googling on this subject I came across this post: Working with Large Applications which explains quite deeply the whole concept of RSLs and linkage, although a bit long for someone who was looking for a quick answer.

So I thought I would write a simple straight forward explanation:

A library in it’s deployment is a SWC.

A SWC combines of a Library.swf with a xml of all the class definitions of the library, called: “Catalog.xml

When you link a library to a project or another library, you sometimes load the actual Library.swf depending on the linkage type, but you always load it’s catalog.xml file into the main application’s ApplicationDomain.

ApplicationDomain” is the storage of all the class definitions of an application, and all of the classes it is allow to refer in build and in runtime.

So, here is a summery of the difference between the linkage types:

Merged into code: loads the library’s catalog.xml to the ApplicationDomain and compiles it’s library.swf into the main application swf.

RSL: loads the library’s catalog.xml to the ApplicationDomain and loads only at the start of the runtime the swf into memory, so you could reach a class definition at runtime, and create an instance.

External: loads the library’s catalog.xml to the ApplicationDomain and doesn’t load the swf of the library at runtime, this option expects a preloading of the library swf into the ApplicationDomain.

Lets say you have 3 projects:

  • MainProject (Flex Project)
  • Lib1 (Library Project)
  • Lib2 (Library Project)

If Lib1 is linked to Lib2 via External Linkage, Lib2 must be loaded into memory by MainProject before MainProject loads Lib1, using RSL linkage for example.

If not, on runtime you will get an error of missing or undefined class definitions, when you try to load classes from Lib2.

Linking as external between library projects saves you both compiling and loading time, just remember to preload them as RSLs in your main application first…

Leave a Reply

Flex Tips and gems of code…