从加载类控制加载的 SWF 的子影片剪辑

发布于 2025-01-02 01:15:37 字数 254 浏览 6 评论 0原文

我有一个已编译的 swf 文件(我们称之为“cat.swf”),它是通过我的主电影的加载器类加载的。猫看起来没有问题。但在 cat.swf 内部定义了两个影片剪辑(我们称它们为“头部”和“主体”),我需要找到一种方法来从我的主影片中控制这些影片剪辑。

当我检查加载器对象的 numChildren 时,它只返回一个(一个未命名的实例),如果我将其转换为一个 Movieclip 来检查更深的子对象,它会像乌龟塔一样一直向下。

如何从加载的电影中访问“head”?

I have a compiled swf File (lets call it "cat.swf") that is loaded via the Loader Class of my Main movie. The cat appears without problems. But inside cat.swf there are two movieclips defined (lets call em "head" and "body"), and I have ye to find a way to get control of these from my Main movie.

When I check for numChildren of the loader Object it only gives me back one (an unnamed instance), if I cast that as a Movieclip to check for deeper children it continues all the way down like a tower of turtles.

How can I get access to "head" from my loading Movie?

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

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

发布评论

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

评论(1

遥远的绿洲 2025-01-09 01:15:37

使用 Loader.content 来访问已加载 SWF 的根 MovieClip。如果您为 MovieClip 的基类指定一个接口,其中包含 headbody 的 getter,您可以将 myLoader.content 转换为它并访问直接以类型安全的方式剪辑。但如果只是这两个,您当然也可以使用括号语法:

var head : DisplayObject = myLoader.content["head"];

如果您没有将 head 和 body 声明为字段,您还可以

var head : DisplayObject = DisplayObjectContainer (myLoader.content).getChildByName ("head");

通过其舞台名称来访问剪辑。

Use Loader.content to access the root MovieClip of the loaded SWF. If you specify an interface to the MovieClip's base class, which contains getters for head and body, you can cast myLoader.content to it and access the clips directly in a type-safe way. But if it's just these two, you can of course use bracket syntax, too:

var head : DisplayObject = myLoader.content["head"];

If you have not declared the head and body as fields, you can also use

var head : DisplayObject = DisplayObjectContainer (myLoader.content).getChildByName ("head");

to access the clip via its stage name.

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