如何导入文档类文件并在框架上播放它
我有 2 个 Flash 文件,一个带有简介,第二个只有一个可以玩贪吃蛇游戏的文档类文件。我如何导入该文档 Flash 文件并使其在其他 Flash 文件的第 100 帧上播放。
谢谢你的帮助。
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.
Thankyou for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在介绍中实例化 Snake 类文件,在第 100 帧上使用如下代码:
假设您的文档类名为
SnakeGame
。不过,您可能需要在SnakeGame
中进行一些更改才能使其正常工作。使用此方法时,SnakeGame
的stage
和root
属性在构造函数中将为 null。这与文档类(或直接放置在舞台上)的行为不同 -stage
和root
已经初始化。因此,如果您在构造函数中对root
或stage
执行任何操作,则必须更改此设置,否则将收到错误。要解决此问题,请侦听Snake
中的ADDED_TO_STAGE
事件:或者,您可以将
Snake
类链接到空的 MovieClip 元件并将其直接放置在舞台上第 100 帧上。首先,通过转到“窗口”->“库”并单击“+”来创建一个空的影片剪辑。在“创建新符号”对话框中,选中“导出为 ActionScript”,然后在“链接”下的“类”字段中输入Snake
。现在,您可以将该 MovieClip 直接拖到舞台上的第 100 帧上,希望它无需更改代码即可正常工作。You can instantiate the Snake class file in your intro, using code like the following on frame 100:
assuming your document class is called
SnakeGame
. You may have to make a few changes inSnakeGame
for this to work, however. Thestage
androot
properties ofSnakeGame
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
androot
are already initialized. So if you do any actions to eitherroot
orstage
in the constructor, you must change this or you will get an error. To fix this, listen for theADDED_TO_STAGE
event inSnake
: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 inSnake
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.