I apologize for not being able to give the walkthrough in terms of Flex
Builder; I work on the lower level, so I'm going to talk in terms of the
command line.  Hopefully you'll be able to translate.  You might want to
walk through it using the low level tools anyway, because its hard to
tweak project settings for experimentation like this.  I'm a big fan of
using ant to automate a build when you get to the point where you're
using RSLs.

Anyway.

The key insight in this is that a SWC is a library, and contains a SWF
(runtime definitions) and some additional metadata (used by the compiler
for dependency tracking, among other things).  SWCs are just zipfiles.
You can look inside them.

Your first step should be to figure out how to use SWCs for static
linking, never mind RSLs.  Get a project set up to build a SWC, then get
your app set up to use that SWC.

Lets say you have an app with "app.mxml", "xyzzy.as", and "plugh.as".

project/src/app.mxml
project/libsrc/xyzzy.as
project/libsrc/plugh.as
project/lib/
project/bin/

Normally, you might compile:

% cd project/src
% mxmlc -o=../bin/app.swf -actionscript-classpath+=../libsrc app.mxml

which would pull in xyzzy and plugh via dependencies.  To convert this
to use libraries, you might do:

% cd project
% compc -actionscript-classpath+=libsrc -o=lib/mylib.swc xyzzy plugh

resulting in project/lib/mylib.swc

To rebuild your app, you'd use:

% cd project/src
% mxmlc -o=../bin/app.swf -library-path+=../lib/mylib.swc app.mxml

We're ready to recompile our application to use the RSL.  This is a bit
complex at first glance, but that is because there are three dimensions.

1) Tell the compiler to not link certain classes into your application.
2) Get the RSL deployed so that it can be found and used at runtime.
3) Tell the compiler to generate some extra stuff that loads your RSL.

Lets just tackle #1 for the moment, and see where it leads us.

% cd project/src
% mxmlc -o=../bin/app.swf -external-library-path+=../lib/mylib.swc
app.mxml

If you run app.swf now, you'll get a RTE, because "xyzzy" and "plugh"
aren't defined.  The external-library-path configuration option says
"compile against these libraries, but leave out every definition that
they define".  There's a corresponding "-externs" option, if you wanted
to do it class-by-class, but its generally a lot more convenient to do
it this way.

So, on to #2.  Lets get the RSL ready for use.

Converting our SWC to a RSL is easy.  Its already halfway there, you
just need to extract out the SWF inside, since the player doesn't
understand SWCs.

% cd project/lib
% unzip mylib.swc library.swf
% mv library.swf ../bin/myrsl.swf

For convenience, I just renamed and moved the library SWF file down so
that its in the same directory as the application SWF.  Honestly, half
the battle for RSLs is just figuring out where to deploy things.

Finally, lets recompile the application to use that RSL:

% cd project/src
% mxmlc -o=../bin/app.swf -external-library-path+=../lib/mylib.swc
-runtime-shared-libraries=myrsl.swf app.mxml

What this does is generate a SWF that will dynamically load the RSL
before letting the application run.

Make sense?

(Note: there are a couple more steps involved if your main application
is built in pure AS instead of MXML, because the code that does the RSL
loading is actually inside your application's "bootstrap class"
(normally a class derived from SystemManager for MXML apps).  In a pure
AS app, you might not have a bootstrap class unless you go out of your
way to use one.)

-rg

> -----Original Message-----
> From: [email protected] 
> [mailto:[EMAIL PROTECTED] On Behalf Of bussesven
> Sent: Tuesday, March 21, 2006 6:05 AM
> To: [email protected]
> Subject: [flexcoders] Runtime Shared Libraries (flex 2)
> 
> Hi,
> 
> i have a question concerning runtime shared libraries in Flex 
> 2. I have 
> read through the documentation but i don't get it. Can 
> someone give me 
> an example on how rsl are created and used? I want to have a rsl that 
> holds some classes that i want to use in several other applications.
> 
> How do i reference a class, that lies in a rsl? With the Embed tag?
> 
> thank you
> 
> 
> 
> 
> 
> --
> Flexcoders Mailing List
> FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
> Search Archives: 
> http://www.mail-archive.com/flexcoders%40yahoogroups.com 
> Yahoo! Groups Links
> 
> 
> 
>  
> 
> 
> 


--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 


Reply via email to