ActionScript 2,嵌套影片剪辑列表

发布于 2024-07-12 04:02:30 字数 296 浏览 7 评论 0原文

有没有人尝试过获取 Flash 8、AS 2 中舞台上指定停止(和当前)帧的所有影片剪辑(甚至是嵌套的)的列表?

我执行了以下操作:

for(i in _root){
if(typeof(_root[i])=="movieclip"){
trace(_root[i]);}
}

但这对于第一级搜索很有用:也就是说,如果在影片剪辑内有其他影片剪辑,则您无法访问它们。 此外,在一个影片剪辑内可以有多个影片剪辑。

有没有人尝试过做我想做的事?

再见!

has anyone ever tried to get the list of all the movieclips (even the nested ones) that are on Stage at a specified stopped (and current) frame in Flash 8, AS 2?

I did the following:

for(i in _root){
if(typeof(_root[i])=="movieclip"){
trace(_root[i]);}
}

But this is good for a first level search: that is, if inside the movieclips you have other movieclips, you can't reach them. Furthermore, inside a movieclip there can be more then one movieclip.

Has anyone ever tried to do what I'm trying to do?

Bye!

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

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

发布评论

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

评论(6

就像说晚安 2024-07-19 04:02:30

完全按照 inkedmn

printStuff 的建议,首先检查它找到的值是否是 mc,如果是,则进行跟踪,然后在其中检查更多 mc。

printStuff = function(object){
    for(var x in object){
        if(typeof(object[x])=="movieclip"){
            trace(object[x]);
            printStuff(object[x]);
        }
    }
}
printStuff(_root);

哦....抱歉一年了,有些改变晚了...

exactly as suggested by inkedmn

printStuff first checks to see if the value it finds is a mc then if it is, traces and then checks inside it for more mcs.

printStuff = function(object){
    for(var x in object){
        if(typeof(object[x])=="movieclip"){
            trace(object[x]);
            printStuff(object[x]);
        }
    }
}
printStuff(_root);

oh....and sorry for being a year and some change late...

铃予 2024-07-19 04:02:30

你只是想追踪吗? 如果是这样,有一个名为 ObjectDumper 的不错的小型未记录实用程序可以执行此操作。

这可能是最好的解释

那么你可以做什么这样做是这样的:

import mx.data.binding.ObjectDumper;

trace(ObjectDumper.toString(_root));

那里可能有很多额外的东西(函数,变量等),所以你可以使用额外的参数:

ObjectDumper.toString(obj, showFunctions, showUndefined, showXMLstructures, maxLineLength, indent)

Are you just trying to trace? If so there's a nice little undocumented utility called ObjectDumper that can do this.

This is probably the best explanation of it out there

So what you can do is this:

import mx.data.binding.ObjectDumper;

trace(ObjectDumper.toString(_root));

There may be a lot of extras (functions, variables, etc) in there, so there are additional parameters you can use:

ObjectDumper.toString(obj, showFunctions, showUndefined, showXMLstructures, maxLineLength, indent)
紫南 2024-07-19 04:02:30

您可以通过向 MovieClip 类添加一个函数来执行类似的操作:

MovieClip.prototype.StopEverything = function()
{
    stop();
    for (var i in this) {
        if (typeof(this[i]) == "movieclip") {
            this[i].StopEverything();
        }
    }
}
ASSetPropFlags(MovieClip.prototype, ["StopEverything"], 1);

我发现最后一点 ASSetPropFlags 允许 StopEverything 对每个字段(甚至隐藏的属性和项目)使用 for..in 迭代内置类,例如 MovieClip。 如果没有 ASSetPropFlags,StopEverything() 可能不会命中每个包含的影片剪辑。

You can do something like that by adding a function to the MovieClip class:

MovieClip.prototype.StopEverything = function()
{
    stop();
    for (var i in this) {
        if (typeof(this[i]) == "movieclip") {
            this[i].StopEverything();
        }
    }
}
ASSetPropFlags(MovieClip.prototype, ["StopEverything"], 1);

That last bit ASSetPropFlags is something I found that allows StopEverything to iterate over built-in classes like MovieClip using for..in for every field, even hidden properties and items. Without ASSetPropFlags, StopEverything() might not hit every contained movie clip.

歌入人心 2024-07-19 04:02:30

我的 AS2 经验非常有限(我已经完成了一些 AS3),但是这里是:

如果你编写一个递归函数,如果它遇到一个影片剪辑,它将查找它的所有子对象以查找其他影片剪辑(并且做了对于在那里找到的任何电影剪辑都是一样的,等等)? 该函数可以采用对象参数,以及每次传递时添加的“找到的”剪辑数组。

我希望我可以编写可以执行此操作的代码,但是(正如我所说),我不太喜欢 AS2 :\

My AS2 experience is pretty limited (I've done bit of AS3), but here goes:

What if you wrote a recursive function that, if it encountered a movieclip, would look through all of it's child objects for other movie clips (and did the same for any movieclips it found there, etc.)? The function could take object parameter, as well as an array of "found" clips that is added to on each pass.

I wish I could write the code that would do this, but (as I said), I'm not much of an AS2 guy :\

萤火眠眠 2024-07-19 04:02:30

我今天做了与此非常相似的事情。 我的剪辑是导航的一部分,并且是一个影片剪辑的重复项。 为了找出有多少个,我在主舞台上放置了一个变量,该变量通过影片剪辑中的动作递增。 我设置了一个时间间隔,等待所有剪辑都被处理完毕,然后使用循环来填充导航的交互性。 效果也很好。 希望这对某人有帮助。

I did something very similar to this today. My clips where part of a navigation and were duplicates of one movieclip. In order to find out how many there were I put a variable on the main stage that was incremented up by actions in the movieclips. I set a interval to wait till all the clips were account for, then used a loop to fill in the interactivity to my navigation. Works pretty well too. Hope this helps someone.

不知在何时 2024-07-19 04:02:30

AS2.0 未记录的 ObjectDumper 功能没有在根枚举影片剪辑的原因是,它忽略了对象根级别的 nameValue 对,这是一个严重的缺陷(至少可以这么说),因为关联数组的定义本身就是一个数组/对象,由其根部的 nameValue 对组成。

例如:trace(ObjectDumper.toString({myName:"myValue"})) //output = "". 难怪他们没有记录这个“功能”。 坦率地说,我认为令人惊讶的是,无论是 AS2 还是 AS3,都没有内置方法可以轻松可靠地枚举对象的所有内容以进行调试。 如果你在网上搜索,你会发现都是 for...in 循环的黑客工作,只查看数组的根......没有递归。

The reason the AS2.0 undocumented ObjectDumper feature does not enumerate movieclips at the root is because it ignores nameValue pairs at the Object's root level, which is an egregious flaw (to say the least), since the very definition of an associate array is an array/object that is made up of nameValue pairs at it's root.

For example: trace(ObjectDumper.toString({myName:"myValue"})) //output = "". No wonder they left this "feature" undocumented. Frankly, I think it's amazing that there is no built-in way to easily and reliably enumerate all the contents of an object for debugging purposes in either AS2 nor AS3. If you search the net all you'll find are hack jobs of for...in loops that only look at the root of an array ... nothing recursive.

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