对象主要时间,对象级和根在AS3之间的区别是什么?对象、区别、时间

2023-09-08 11:25:22 作者:念文

我想知道的的区别[对象主要时间] [对象舞台] 和根?

我已经从话题的如何舞台,根和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

第一阶段可能是最容易理解的。有一个阶段,每个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根将参考其自己的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编辑器中看到的影片剪辑。这是哪里的时间表code保持并在添加时间轴动画。文档类可以凌驾与自定义类。改变文档类将改变该根是指对象的类型。

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 type of object that root refers to.

正如我的类型人,时间线是默认类型MainTimeline。如果我的原子是在一个远程搬运工被错位和余改变为一个不同类型的东西,如FreakOfNature,这将类似于改变文档到不同类 - 的结果是,在时间线将成为一个不同类型的东西。

Just as I am of type "Human", the timeline is of default type "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文件,并添加以下时间表code:

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,并注意输出。需要注意的是在时间轴code在类型的影片剪辑MainTimeline。这是根提到了同一个实例。在MainTimeline实例的母公司为舞台。

2.Run the FLA and take note of the output. Note that the timeline code is in a movie clip of type "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.设置文档类自己的类(如:测试)。需要注意的是类没有实际存在 - 闪存将提示您自动创建

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.Run的FLA并注意新的输出。需要注意的是在时间轴code是现在式不同的影片剪辑测试。 测试是被添加到舞台的电影剪辑的类型。

4.Run the FLA and note the new output. Note that the timeline code is now in a different movie clip of type "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的默认类文档类,除非凌驾与自己的。文档类的一个实例(无论是MainTimeline或自己的类)添加到该SWF加载阶段。

From this we can see that Flash uses a default class of type 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.