是否有关于 Flash 如何跨关键帧管理命名实例的文档?

发布于 2024-10-20 14:24:36 字数 609 浏览 3 评论 0原文

我正在寻找有关 Flash 如何跨关键帧管理同名对象实例的技术文档。

到目前为止,我注意到,当播放头移动到另一帧时,如果具有相同名称的对象具有相同的类型,则该实例及其动态设置的属性将被保留。

另一方面,一旦播放头转到命名实例是不同类型的帧,它就会创建新类型的新实例(具有原始名称),而旧类型的原始实例是永久丢弃,命名实例上的所有动态设置属性都将丢失(因为它是新实例)。

如果返回到原始帧,它不会恢复原始实例,而是将其视为另一个更改,并再次构造一个新实例。有没有描述这种行为的文档?

关于“时间线实例的连续性”的类似问题: http://www.kirupa.com /forum/showthread.php?t=316612 我也对财产继承感到惊讶。这似乎是一个运行时功能,只有当(实例名称/符号类型)对在下一个关键帧中发生变化时,Flash 才会创建一个新实例(即,如果命名实例“obj”在两个关键帧中都引用“球”)关键帧,那么它将保持相同的实例;但如果“obj”引用下一个关键帧中的“square”,则将创建“square”的新实例)。这是有道理的,但是这种行为有保证吗?

I'm looking for technical documentation on how Flash manages object instances with the same name across key frames.

So far, I've noticed that when the play head moves to another frame, if an object with the same name has the same type, then the instance is preserved along with its dynamically set properties.

On the other hand, as soon as the play head goes to a frame where the named instance is a different type, then it creates a new instance of the new type (with the original name), and the original instance of the old type is permanently discarded and all dynamically set properties on the named instance are lost (because it's a new instance).

If you go back to the original frame, it does not restore the original instance, but treats it as yet another change, and constructs a new instance again. Is there any documentation that describes this behavior?

Similar question on "continuity of timeline instances": http://www.kirupa.com/forum/showthread.php?t=316612
I too was surprised that properties carry over. It seems like a run-time feature, where Flash will create a new instance, only if the (instance name / symbol type) pair changes in the next key frame (i.e. if named instance "obj" refers to a "ball" in both keyframes, then it will remain the same instance; but if "obj" refers to a "square" in the next keyframe, then a new instance of "square" will be created). It makes sense, but is this behavior guaranteed?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

瞄了个咪的 2024-10-27 14:24:36

这太长了,无法在评论中发布,但我发现了使用框架脚本的各种其他行为。

到目前为止,在不同关键帧上具有相同实例名称的对象会导致仅在以下情况下创建新实例

  1. 不同的符号类型或
  2. 相同的符号类型和不同的图层
  3. 导航到中间关键帧,该中间关键帧不会不包含对象

换句话说,只要实例名称、符号类型和对象所在的图层在帧与帧之间保持相同,并且每个帧都包含命名实例,则单独的过滤和变换不会导致新实例待创建。

当涉及到 ActionScript 时,事情就会变得有趣。

---如果您使用脚本删除对象:---

相同的实例名称、相同的符号类型、相同的图层:

  1. 如果您在第 1 帧上使用removeChild 删除对象,则在第 2 帧上不会创建新对象。事实上,旧对象仍然存在,但它不可见,并且没有应用第 2 帧中的任何变换(即对象保留其原始大小、滤镜等)。
  2. 如果您在第 1 帧上使用 removeChild 删除对象,然后立即重新添加该对象,则该对象将持续存在并在第 2 帧中可见,但仍然不会应用第 2 帧中的任何变换(即对象保留其原始大小,过滤器等)。

相同的实例名称,相同的符号类型,不同的图层:

  1. 如果删除该对象,则会按预期在第二帧上创建一个新对象,因为它位于不同的图层上。位于不同的层上几乎可以保证将创建一个新对象,正如您将从下一个语句中看到的那样...

  2. 如果删除该对象,则立即重新添加它 (removeChild(obj); addChild(obj) );),那么你最终会得到一个重复,因为在第 2 帧上具有新变换的新实例仍然被创建,并且原始对象仍然存在(而如果你没有删除/添加它,关键帧更改将破坏它) .

总结

在关键帧中,唯一会触发创建具有相同实例名称的新对象的情况是该对象具有不同的符号类型或位于不同的图层上,或者您访问不包含该对象的关键帧然后返回到一个这样做的地方。其他任何事情都不会导致创建新实例。使用 ActionScript 删除对象(即使您立即重新添加它)将导致播放器不会对对象应用新的关键帧变换,但其本身不会触发新实例的创建。

This is too long to post in the comments, but I discovered various other behaviors using frame scripts.

So far, an object with the same instance name on different key frames causes new instances to be created only when we have:

  1. different symbol type or
  2. same symbol type and different layer
  3. navigate to an intermediate key frame that does not contain the object

In other words, as long as instance name, symbol type, and layer the object is on remains the same from frame to frame, and each frame contains the named instance, then filters and transforms alone won't cause new instances to be created.

Things get interesting when ActionScript is involved.

---If you REMOVE THE OBJECT WITH A SCRIPT:---

Same instance name, same symbol type, same layer:

  1. If you remove the object with removeChild on frame 1, then on frame 2 no new object is created. In fact, the old object still exists, but it's not visible and NONE of the transforms from frame 2 are applied (i.e. the object retains its original size, filters, etc.).
  2. If you remove the object with removeChild on frame 1, and then immediately re-add the object, then it persists and is visible in frame 2, but still NONE of the transforms from frame 2 are applied (i.e. the object retains its original size, filters, etc.).

Same instance name, same symbol type, different layer:

  1. If you remove the object, a new one is created on the second frame as expected, since it was on a different layer. Being on a differnet layer is almost a guarantee that a new object will be created as you will see from the next statement...

  2. If you remove the object then immediately re-add it (removeChild(obj); addChild(obj);), then you end up with a DUPLICATE, because the new instance with new transforms on frame 2 is still created AND the original object remains (whereas if you had not removed/added it, the key frame change would have destroyed it).

Summary

Across key frames, the only things that will trigger the creation of a new object with the same instance name is if the object has a different symbol type or is on a different layer, or you visit a key frame that does not contain the object and then return to one that does. Nothing else will cause a new instance to be created. Removing the object with ActionScript (even if you immediately re-add it), will cause the player to NOT apply new key frame transformations to the object, but in and of itself will not trigger the creation of a new instance.

离线来电— 2024-10-27 14:24:36

自从我开始使用 Flash 5 中的 AS 以来,我从未见过此官方文档。

您的观察结果与我的一致,但另一种情况是“相同名称,相同类型,新关键帧,不同层”,它重新初始化 AVM1 中的对象。我不确定 AVM2 会做什么,因为我真的尽力避免这些情况,但如果需要的话,这可能是让 MC 在时间轴上重新初始化的好方法。

I have never seen this officially documented since I started with AS in Flash 5.

Your observations match mine, but another case is "same name, same type, new keyframe, different layer" which reinitializes the object in AVM1. I am not sure what AVM2 does, since I really try to avoid these situations, but this can be a decent way to get a MC to reinit on the timeline if you need to.

葬花如无物 2024-10-27 14:24:36

这不是有记录的行为,但您的观察是正确的。但是,如果共享相同实例名称的两个对象属于不兼容的类型,那么您可能会遇到潜在的障碍,因为 Flash 可能会尝试强制第二个(或所有后续对象)“存在”或尝试像第一个一样行事它找到了一个。这可能是 fp9 所特有的,但这种行为足以“伤痕累累”,建议您永远不要让两个不同的对象在同一时间线上共享相同的实例名称。

您可能想查看我针对该主题撰写的有关时间线和实例名称的博客条目为了多一点照明。

我可能没有充分提及的另一件事是,如果您将时间轴声音嵌套在任何可能被“略过”的影片剪辑中,如果您使用 gotoAndStop/Play 来“跳过”,这种行为也会造成巨大的破坏。 “围绕一个时间线。

It isn't a documented behavior but your observations are correct. However, there's a potential snag that can happen to you if your two objects that share the same instance name are of incompatible types in that Flash might try to coerce the second (or all following) into "being" or trying to act like the first one it found. This may have been particular to fp9 but the behavior was 'scarring' enough to advise that you should NEVER have two different objects share the same instance name on the same timeline.

You might want to look at This blog entry on timelines and instance names that I wrote about the subject for a little more illumination.

One other thing that I may or may not have touched on adequately though, is that this behavior can also wreak massive havoc if you've nested timeline sounds in any movieclip that might be "skimmed" over if you use gotoAndStop/Play to "skip" around a timeline.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文