Way to link an swc externally

I have created a flex application and I want to use a third party library (swc) in such a way that

  • I won't have to include the third party swc in my swf at compile time. (I don't want the swc to be a part of my swf)
  • The end user will have my swf and the third party swc. He/She can link those two if required
  • In my application, the code which is using/importing third party library will work only if the end user decides to use third party swc, otherwise it'll be ignored.
  • Basically, I want to have an optional dynamic(runtime) linking to a locally stored swc at user end. If the swc is available, my swf should be able to use it else it doesn't have to.

    Is it possible?


    I'm not sure about SWC but this is how I do it with SWF. Please note I'm copying code from different parts so you may need to fine tune it

            var the_cls:Class;
    
            // First, load SWF with classes:
            var request:URLRequest = new URLRequest( u );
            var loader:Loader = new Loader();
    
            loader.contentLoaderInfo.addEventListener(Event.COMPLETE, function (e:Event){
                // then get class from the file, you can do it for few classes
                the_cls = e.target.applicationDomain.getDefinition("my_ldd_class_name") as Class;
            });
            loader.load(request, new LoaderContext(false, ApplicationDomain.currentDomain));
    
    
    
            // then use class in your application:
            the_obj = new the_cls();
            the_obj.the_func();
    
    链接地址: http://www.djcxy.com/p/35442.html

    上一篇: 输出文件中缺少外观?

    下一篇: 从外部链接swc的方法