重用实例名称为不同的对象 [英] Reuse Instance Names for Different Objects

查看:134
本文介绍了重用实例名称为不同的对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

简单的问题:我怎么能重复使用不同的对象实例名称(当然在不同的帧)?我真的希望能够使用相同的实例名称为我所有的场景,地,尽管这些地面情况是不同类的。我真的不希望有去命名他们ground0,地下1,etc.I认识到,有办法解决这个,但我不想与所有额外的工作鬼混。所以,他这样说,我怎么重用实例名称地面,而不必此警告扔给我:

Simple question: how can I reuse instance names for different objects (obviously on different frames)? I really want to be able to use the same instance name for all my scenes, "ground", even though these ground instances are of different classes. I really don't want to have to go about naming them "ground0", "ground1", etc.I realize that there are ways around this, but I would hate to fool around with all that extra work. So that being said, how do I reuse the instance name "ground" without having this warning thrown at me?:

Menu, Layer 'ground', Frame 1   Warning: The instance name 'ground' is declared on an object of type Ground but there is a conflicting use of the instance name 'ground' on an object of type Ground2.

顺便说一下,我认识到,一个实例应该是一个特定对象的发生,但说实话,我不太明白这一点在没有被允许在适当的时候重新使用实例名称。任何帮助将是非常美联社preciated。

And by the way, I realize that an instance is supposed to be an occurrence of a specific object, but to be honest I don't quite see the point in not being allowed to reuse instance names when appropriate. Any help would be much appreciated.

推荐答案

如果我记得挑剔的Flash怎么样,它可能是与如何对这些帧创建的地面的实例。

If I recall how finicky Flash was, it may have something to do with how you created the "ground" instance on those frames.

到了,我的意思是:

  • 在你创建一个实例,然后再创建新的关键帧之后(意为:同一个实例将在所有关键帧中使用),或者...
  • 你首先先创建空的关键帧,然后将坠/粘贴一地比如在每个帧? (意指:在这种情况下,它可能会被视为独立的3实例)。

我不知道,如果这个假设是正确的,但Flash并不一定配合实例层,如哦,地面上1层,因此每帧应重复使用相同的情况下......。在一个完美的世界,我同意这将是有意义的。但是从闪存时,它主要是针对动画师,在那里任何事情都会发生的早期版本(从具有相同的帧上的多个形状和实例,从组/实例的重新编排上一帧/层的深度),它仍然使如果拖动/从库到舞台复制项目的假设,这并不一定意味着它们是相同的实例。相反,你要照看的Flash与要重用现有资产实例帧之后创造更多关键帧(或补间的关键帧根据您的需要)。

I'm not sure if this assumption is correct, but Flash doesn't necessarily tie instances to layers, as in "Oh, ground is on Layer 1, therefore every frames should reuse the same instance...". In a perfect world, I agree this would make sense. But from the early versions of Flash when it was mostly targeted to animators, where anything goes (from having multiple shapes and instances on the same frame, from re-arranging the depth of groups / instances on one frame/layer), it's still making the assumption that if you drag / copy an item from the library to the stage, it doesn't necessarily mean they are the same instance. Instead, you have to babysit Flash by creating more keyframes (or tween keyframes depending on your need) after the frame with the existing asset instance you want to reuse.

此外,以上是根据我的经验的假设 - 但如果你没有手动输入接地实例名称上的每个帧中的每个实例,没准你previously复制/粘贴或拖动新实例到这些帧。

Again, the above is an assumption based on my experience - but if you did enter the "ground" instance-name manually for each instances found on each frames, chances are you previously copy/pasted or dragged new instances to those frames.

听起来是不是像一些你可能已经做了什么?

Does it sound like something you may have done?

编辑:

如果你有一个跨越几帧,这是不同符号的实例,那么这肯定会引发这些警告你已经得到地的资产。我不知道在那里你可以关闭它们(preferences?项目可能发布设置?高级AS3设置?)......但无论如何,这里有可能为你工作,以编程的方式。

If you have "ground" assets across a few frames, which are instances of different Symbols, then that definitely would trigger those Warnings you've been getting. I'm not sure where you can turn those off (Preferences? Project Publish settings? Advanced AS3 settings maybe?).. but regardless, here's a way that may work for you, programmatically.

由于每帧有一个唯一的实例,每个命名为地面的实例,你可以创建一个辅助函数来工作,如 .getChildByName(地)方法(和说实话,我不知道是否该方法将工作的权利,蝙蝠,你可以试试)。您需要for循环,通过给定MovieClip的孩子(在你的菜单中的孩子,你的情况,我相信?),并检查如果(child.name == theNameInQuestion)返回子; 。 话虽这么说,我不能保证这是正确的解决方案(没有测试),因为我不知道你是如何航行的框架在运行时(播放/停止/的gotoAndPlay / gotoAndStop /等),以及可能影响该地面实例可在给定的时间。在内部,闪光灯确实的addChild / removeChild之换出这些不同的接地实例,通过帧它的周期,它不是一个简单的可见=真/假切换(据我所知)。

Since each frames have a unique instance, with each instances named "ground", you could create a helper function to work like the .getChildByName("ground") method (and to be honest, I'm not sure if that method would work right-off the bat, you could try). You would need to for-loop through the given MovieClip's children (In your Menu's children, in your case I believe?), and check if(child.name==theNameInQuestion) return child;. That being said, I can't guarantee this is THE proper solution (didn't test), as I don't know how you're navigating the frames at runtime (play/stop/gotoAndPlay/gotoAndStop/etc), and that may affect which "ground" instance is available at a given time. Internally, Flash does addChild/removeChild to swap out those various "ground" instances as it cycles through the frames, it's not a simple visible=true/false toggle (AFAIK).

编辑2:

这可能是你需要什么?

这篇关于重用实例名称为不同的对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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