我正在尝试手动加载生成的 swc 构建的 swf。由于我的特殊环境,我们需要将类定义分离到 swcs(这是有意义的)以从输出 swfs 中删除冗余代码。
简而言之,我LibA
在构建的 swf 中定义了一个类 () compc
。我将它编译成 swc 和目录格式,因此我可以轻松地从目录中提取 library.swf 以在运行时加载(外部链接)并使用 swc 从任何使用 Flash CS5 或mxmlc
.
LibA.as:
package
{
public class LibA
{
public function LibA()
{
trace("*** LibA()");
}
}
}
主要作为:
package
{
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.net.URLRequest;
import flash.system.LoaderContext;
public class Main extends Sprite
{
private var self:Main;
private var context:LoaderContext;
public function Main()
{
var l:Loader = new Loader();
self = this;
l.contentLoaderInfo.addEventListener(Event.COMPLETE, function(e:Event) {
self.addChild(l.content);
var liba:LibA = new LibA();
});
l.load(new URLRequest("./libs/build/liba.swf"));
}
}
}
我构建了 swc/目录 swc
compc -output libs/build/liba.swc -include-sources libs/LibA.as -debug=true
并且我在构建时在Flash CS5的AS3设置中设置了适当的链接Main
(直接链接到舞台的类)。
一切都毫无问题地发布。
但是,在运行时我得到VerifyError: Error #1014: Class LibA could not be found.
我在这里想念什么?我希望能够加载和使用liba.swf
从我的Main.swf
.
完整的跟踪转储:
verify Function/<anonymous>()
stack:
scope: [global Object$ flash.events::EventDispatcher$ flash.display::DisplayObject$ flash.display::InteractiveObject$ flash.display::DisplayObjectContainer$ flash.display::Sprite$ Main$ Main Main]
locals: Object flash.events::Event? *
0:getlex 4
stack: Main?
scope: [global Object$ flash.events::EventDispatcher$ flash.display::DisplayObject$ flash.display::InteractiveObject$ flash.display::DisplayObjectContainer$ flash.display::Sprite$ Main$ Main Main]
locals: Object flash.events::Event? *
2:getlex 7
stack: Main? flash.display::Loader?
scope: [global Object$ flash.events::EventDispatcher$ flash.display::DisplayObject$ flash.display::InteractiveObject$ flash.display::DisplayObjectContainer$ flash.display::Sprite$ Main$ Main Main]
locals: Object flash.events::Event? *
4:getproperty content
stack: Main? flash.display::DisplayObject?
scope: [global Object$ flash.events::EventDispatcher$ flash.display::DisplayObject$ flash.display::InteractiveObject$ flash.display::DisplayObjectContainer$ flash.display::Sprite$ Main$ Main Main]
locals: Object flash.events::Event? *
6:callpropvoid addChild 1
stack:
scope: [global Object$ flash.events::EventDispatcher$ flash.display::DisplayObject$ flash.display::InteractiveObject$ flash.display::DisplayObjectContainer$ flash.display::Sprite$ Main$ Main Main]
locals: Object flash.events::Event? *
9:findpropstrict LibA
stack: Object
scope: [global Object$ flash.events::EventDispatcher$ flash.display::DisplayObject$ flash.display::InteractiveObject$ flash.display::DisplayObjectContainer$ flash.display::Sprite$ Main$ Main Main]
locals: Object flash.events::Event? *
11:constructprop 10 0
stack: *
scope: [global Object$ flash.events::EventDispatcher$ flash.display::DisplayObject$ flash.display::InteractiveObject$ flash.display::DisplayObjectContainer$ flash.display::Sprite$ Main$ Main Main]
locals: Object flash.events::Event? *
14:coerce LibA
VerifyError: Error #1014: Class LibA could not be found.