如何导入文档类文件,并发挥它在一个框架它在、框架、文档、文件

2023-09-08 15:23:36 作者:江上晚吟风

我有2个flash文件,其中一个前奏,而只是有播放了蛇游戏的文档类文件中的第二个。我怎么能导入该文件的Flash文件,并使其发挥出像架100关我的其他Flash文件。

I have 2 flash files, one with an intro and the second that just has a document class file that plays out a snake game. How could i import that document flash file and make it play out on like frame 100 off my other flash file.

三江源的任何帮助。

推荐答案

您可以实例化蛇类文件在您的介绍,使用code像架100以下内容:

You can instantiate the Snake class file in your intro, using code like the following on frame 100:

var game:Snake = new Snake();
addChild(game);

假设你的文档类叫做 SnakeGame 。您可能不得不在 SnakeGame 这个工作有一些变化,但是。该 SnakeGame 的属性将在空当使用这种方法构造。这是不同的行为,从它的是文档类(或直接放置在舞台上) - 是已经初始化。所以,如果你做任何操作来在构造函数中,你必须改变,或者你会得到一个错误。为了解决这个问题,需要侦听 ADDED_TO_STAGE 事件

assuming your document class is called SnakeGame. You may have to make a few changes in SnakeGame for this to work, however. The stage and root properties of SnakeGame will be null in the constructor when using this method. This is different behavior from it's was the document class (or placed directly on the stage) -- stage and root are already initialized. So if you do any actions to either root or stage in the constructor, you must change this or you will get an error. To fix this, listen for the ADDED_TO_STAGE event in Snake:

public function Snake() {
    addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
}

public function onAddedToStage(event:Event):void {
    removeEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
    // stage+root are now valid, put your init code here
}

Alterantively,你可以在类链接到一个空的影片剪辑元件和地点直接放在第100帧一阶段,通过将窗口中创建一个空的影片剪辑 - >库并单击+。在创建新元件对话框中,选中为ActionScript导出,并在链接下的类字段中键入。现在,您可以直接拖动影片剪辑到舞台上的帧100,它希望将工作没有改变code。

Alterantively, you could link the Snake class to an empty MovieClip symbol and place that directly on the stage on frame 100. First, create an empty MovieClip by going to Window->Library and clicking the +. In the Create New Symbol dialog, check "Export for ActionScript" and type in Snake in the Class field under Linkage. Now you can drag that MovieClip directly onto the stage on frame 100 and it hopefully will work without changes to the code.