loading an RSL without using flex?

女生的网名这么多〃 提交于 2019-12-05 07:35:21

问题


If I have rolled my own RSL, and I want to use it in my pure as3 apps, is there documentation or an example of how to do this?

Or do I need to traverse the flex source code to figure out what adobe's engineers have done?


回答1:


This is a very tricky one, with lots to go into I'm afraid. Some pointers:

To get a class from an externally loaded SWF use the getDefinition method on an application domain e.g.

public function loadHandler(evt:Event):void
{
   var loaderInfo:LoaderInfo = evt.target as LoaderInfo;
   var clazz:Class = loaderInfo.applicationDomain.getDefinition("your.external.class");
}

This will give you the class definition if you know the name of the class you want.

To 'join' class domains into each other (so applications can compile against a swc, but not include the classes and load them externally) you need to specify a loaderContext of the same security domain.

var loader:Loader = new Loader();
var context:LoaderContext = new LoaderContext();
context.applicationDomain = ApplicationDomain.currentDomain;
loader.load(new URLRequest("library.swf"), context);

The third pointer I can give you is the compiler option "-external-library-path", use this to specify a list of swc's to compile time check against, but not include (resulting in a lower filesize).

mxmlc -source-path="dir/src" -external-library-path="dir/lib/framework.swc" --main.swf

Sorry I couldn't elaborate more, it's a very expansive topic, hope this gets you started....



来源:https://stackoverflow.com/questions/1201659/loading-an-rsl-without-using-flex

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!