RSS Feed Email Feed

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 libraries 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. BUT , And this is a big one – Only the classes you use in the library will be compiled !!

That means that if you don’t use a certian component, it won’t be included in the catalog.xml and you can’t call it at runtime.

RSL: loads the library’s catalog.xml to the ApplicationDomain (unlike “merge into code”, this one includes all the classes) and also loads the swf into memory only at the start of the runtime , 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…

6 Comments

Jyoti  on December 15th, 2010

Hello,
Great post. I was searching about this topic since morning and now my confusion is clear. So I thought I must thank you.

Your blog has so simple and useful info. I have also created a bookmark of it. So please keep up this great work and let us know more about flex.

thanks
Jyoti

Shai R  on December 19th, 2010

Thanks Jyoti, Great to hear it helped…

Sebz  on February 24th, 2011

Hi,

You just saved my life !
I’ll definitely follow your blog :)

Thanks a lot !

Jeff Monson  on March 30th, 2011

If a client loads two different Flex applications, won’t the application load overlapping class definitions? I’m thinking this can be a problem for users who are on dialup or slow network connections.

Many Thanks,
Jeff Monson
Webmaster – JLM Merchandise Surveillance and Security Products

MLM Marketing  on April 1st, 2011

We’ve found linking to an External library catalog.xml hosted on a cloud server of some kind really seems to minimize server load resources which is important there are a lot of calls to the app. Great work. Thanks for sharing.

Steven  on January 28th, 2012

This post was very useful to me thanks alot!

Leave a Comment