>but the documentation says it will retrieve and load into
 >memory as needed.

I haven't looked at the exact verbiage in the docs but you have to 
manually manage the loading of the external dependencies. As far as I 
understand it, the ActionScript byte code needs to be accessible by the 
time your code references anything in the library. There are a few 
scenarios in which you might accomplish this. The most obviously likely 
being using Loader to load the library SWF. As soon as you get the 
Event.INIT event back you should be able to access code / classes in the 
library. Be sure you give the Loader a LoaderContext object that sets 
the ApplicationDomain to the current domain. Here's a little example...

private function loadLib():void
{
    var context: LoaderContext = new LoaderContext(false, 
ApplicationDomain.currentDomain);
    var request: URLRequest = new URLRequest("library.swf"); // 
library.swf extracted from SWC
    var loader: Loader = new Loader();
    loader.contentLoaderInfo.addEventListener(Event.INIT, 
this.handleLibInitialized);
    loader.load(request, context);
}

private function handleLibInitialized(event: Event): void
{
    trace(Constants.COMPANY_NAME);
    this.coname = Constants.COMPANY_NAME;
}



passive_thoughts wrote:
> I don't fully understand this link type.
>
> I realize that by setting a library(swc) as external in an app, it is
> used as a reference for the compiler during compile time.  Now the
> documentation says "The components contained in the SWC file are
> retrieved and loaded into memory as needed, at run time."
>
> I created a simple flex library that has one class and in the class
> one static string with a value of "abc metals ltd.".  The library
> compiles fine. I add the swc to my app and leave it as merged.  I add
> these lines to my app:
>
> import com.abc.library.Constants;
> private var coname:String =  Constants.COMPANY_NAME;
>
> and it works fine.  If I change it to Link Type RSL and run it, it
> works fine as well.  If I change it to Link Type External, it compiles
> but errors out at run time:
>
> ReferenceError: Error #1065: Variable com.abc.library::Constants is
> not defined.
>
> Now this sort of makes sense... I haven't merged my library, nor have
> I included it as an RSL so my app has no idea where to find this
> code... but the documentation says it will retrieve and load into
> memory as needed.   How and from where?  And really what is the point
> of this type?
>
> Any advice is much appreciated!
>
> Vic
>
>   



--
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/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> 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