在课堂上加载具有舞台参考的外部SWF

时间:2011-11-17 06:14:12

标签: flash actionscript-3

由于基类中的Stage引用,我无法通过外部swf加载forces.swf(假设我无法编辑它,因为我没有源代码)。

如何在不抛出错误的情况下加载它(以及任何其他可能的SWF)?

以下是我要解决的问题的链接:

http://www.mediafire.com/?9d9qay8a6xj7836

感谢。

1 个答案:

答案 0 :(得分:0)

如果你正在使用加载的SWF并希望它们使用舞台,首先需要在舞台上添加它们(不像默认的SWF出现在舞台上)。

所以你需要使用这样的东西:

public function YOURCLASS()
{
    // at this point if the swf is externally loaded, it is only in the memory
    // but not on stage. you can "trace ( stage )" it will give you NULL

    // you need to listen to the event when the object was added on stage.
    addEventListener(Event.ADDED_TO_STAGE, handleAddedToStage);
}

private function handleAddedToStage(e:Event):void
{
    removeEventListener(Event.ADDED_TO_STAGE, handleAddedToStage);
    // now the object is added on the stage, and you can refer the stage parameter
    // "trace ( stage )" it will give you [Stage]
}
希望它有所帮助。

<强>更新

理论上它应该是这样的:

从SWF

您需要创建一个SWC文件(这是解决方案的理论部分)

然后你有一个NewClass扩展了Constructor类而你没有调用super();

...我仍然不知道从SWF创建SWC的内容是什么......

相关问题