简体   繁体   English

如何在另一个addup_to_stage中导入swf? (AS3,闪光灯)

[英]how to import swf in another one, added_to_stage? (as3, flash)

i have a class Team.as that imports another class CustomMenu.as . 我有一个类Team.as ,它导入另一个类CustomMenu.as This works fine, when i launch Team.fla, the content of CustomMenu appears well. 这很好,当我启动Team.fla时,CustomMenu的内容看起来很好。

But, in my project, Main.as imports Team.swf , and then the content of Team appears on screen EXCEPT the content of CustomMenu.as . 但是,在我的项目中, Main.as导入Team.swf ,然后除CustomMenu.as的内容外, Team的内容显示在屏幕上。

So, i added a ADDED_TO_STAGE to the three of them, by example : 因此,通过示例,我向其中三个添加了ADDED_TO_STAGE

    public function Team() {
        addEventListener(Event.ADDED_TO_STAGE, initStage);
    }

    public function initStage(e:Event){

But CustomMenu never appears in the loader. 但是CustomMenu永远不会出现在加载程序中。 It's not a problem with the size of the container, or anything like that, because i tried to put a black rectangle in the loaded swf and it works. 这与容器的大小或诸如此类的大小无关,因为我试图在加载的swf中放置一个黑色矩形,并且它可以工作。 Do you have any solution? 你有什么解决办法吗?

Thanks a lot 非常感谢

Is initStage(e:Event) called when you addChild(myTeam); 当您添加child(myTeam)时调用initStage(e:Event); in your main project file? 在您的主项目文件中?

You can just write some public init() method in Team class. 您可以在Team类中编写一些公共的init()方法。 Then cast your loaded content in main file to Team(loadedSWF), then call Team(loadedSWF).init() when you make sure it's already on the stage. 然后将已加载的内容从主文件投射到Team(loadedSWF),然后在确保已在舞台上时调用Team(loadedSWF).init()。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM