as3中的对象主时间轴、对象舞台和根有什么区别? [英] What is the difference between object main timeline, object Stage and root in as3?

查看:18
本文介绍了as3中的对象主时间轴、对象舞台和根有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道as3中[object main timeline][object Stage]root的区别?

I want to know the difference between [object main timeline], [object Stage] and root in as3?

我已阅读主题 stage、root 和 MainTimeline 如何组合在一起.但是没看清楚.

I have read from the topic How stage, root, and MainTimeline Fit Together. But I didn't get clearly.

推荐答案

我认为你链接到的文章总结得很好(即使它没有很好地解释它):

I think the article you linked to sums it up quite nicely (even if it doesn't explain it all that well):

总结:一个阶段,每个 SWF 一个根(这是主时间线)并且根是文档类或 MainTimeline 的实例如果未提供文档类,则为类

To summarize: one stage, one root per SWF (which is the main timeline) and that root is an instance of a document class or the MainTimeline class if a document class isn't provided

Stage 可能是最容易理解的.每个 Flash Player 有一个舞台 - 将其视为播放 Flash 影片的窗口.它是最顶层的显示对象 - 出现在屏幕上的任何内容都是舞台的子级.舞台始终是同一个实例,任何对舞台的引用都返回相同的值.

Stage is probably the easiest to understand. There is one stage per Flash Player - think of it as the window that the Flash movie plays in. It is the top-most display object - anything that appears on the screen is a child of the stage. The stage is always the same instance and any reference to stage returns the same value.

Root 是特定 SWF 文件的显示层次结构的逻辑顶部".正如文章中所解释的,每个 SWF 都有自己的根,它指的是该 SWF 的文档类的实例.

Root is the a logical "top" of the display hierarchy for a specific SWF file. As explained in the article, every SWF will have it's own root, which refers to the instance of the document class for that SWF.

在运行时将一个 SWF 加载到另一个 SWF 时,您可以看到 root 和 stage 之间的不同.两个 SWF 将具有不同的根但处于相同的阶段.每个 SWF 中的根将引用其自己的 SWF 的最顶层显示对象,即它们的文档类.

You can see the different between root and stage when loading one SWF into another at run-time. Both SWFs will have a different root but the same stage. The root in each SWF will refer to the top-most display object of their own SWF which is their document class.

MainTimeline 是用于文档类的默认类.文档类是在加载 SWF 电影时添加到舞台的显示对象.在它下面是一个扩展 MovieClip 的普通类.

MainTimeline is the default class used for the document class. The document class is the display object which is added to the stage when the SWF movie is loaded. Underneath it is a normal class which extends MovieClip.

文档类是您在 Flash 编辑器中看到的 MovieClip.这是保存时间线代码和添加时间线动画的地方.文档类可以被自定义类覆盖.更改文档类将更改 root 所指对象的名称.

The document class is the MovieClip you see in the Flash editor. This it is where timeline code is kept and where timeline animations are added. The document class can be over-ridden with a custom class. Changing the document class will change the name of the object that root refers to.

正如我被称为人类"一样,时间线在默认情况下被称为MainTimeline".如果我的原子在传送器中被破坏并且我被更改为不同类型的东西,例如FreakOfNature",这将类似于将文档更改为不同的类 - 结果是时间线将变成一个不同类型的东西.

Just as I am referred to as "Human", the timeline is referred to by default as "MainTimeline". If my atoms were to be mangled in a tele-porter and I was changed to a different type of thing such as "FreakOfNature", this would be similar to changing the document to a different class - the result is that the timeline would become a different type of thing.

您可以通过以下测试来说明阶段、根目录和文档之间的关系:

Here's a test you can do to illustrate how the stage, root and document relate:

1.创建一个空的FLA文件,并添加如下时间线代码:

1.Create an empty FLA file, and add the following timeline code:

trace("this " + this);
trace("root " + root);
trace("root.parent " + root.parent);
trace("stage " + stage);
trace("parent " + parent);

2. 运行 FLA 并记录输出.请注意,时间线代码位于扩展名为MainTimeline"的影片剪辑的类中.这与 root 引用的实例相同.MainTimeline 实例的父级是 Stage.

2.Run the FLA and take note of the output. Note that the timeline code is in a class that extends movie clip of name "MainTimeline". This is the same instance referred to by root. The parent of the MainTimeline instance is Stage.

this [object MainTimeline]
root [object MainTimeline]
root.parent [object Stage]
stage [object Stage]
parent [object Stage]

3.将文档类设置为您自己的类(例如:Test").请注意,该类实际上不必存在 - Flash 会提示您自动创建它.

3.Set the document class to your own class (eg: "Test"). Note that the class doesn't actually have to exist - Flash will prompt you to create it automatically.

4. 运行 FLA 并注意新输出.请注意,时间线代码现在位于扩展名为Test"的影片剪辑的不同类中.测试"是添加到舞台的影片剪辑的类型.

4.Run the FLA and note the new output. Note that the timeline code is now in a different class that extends movie clip called "Test". "Test" is the type of the movie clip which is added to the stage.

this [object Test]
root [object Test]
root.parent [object Stage]
stage [object Stage]
parent [object Stage]

由此我们可以看到,Flash 为文档类使用了一个名为 MainTimeline 的默认类,除非被您自己的类覆盖.加载 SWF 时,会将文档类的实例(无论是 MainTimeline 还是您自己的类)添加到舞台.

From this we can see that Flash uses a default class named MainTimeline for the document class, unless over-ridden with your own. An instance of the document class (be it MainTimeline or your own class) is added to the stage when the SWF is loaded.

这篇关于as3中的对象主时间轴、对象舞台和根有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆