访问脚本上的影片剪辑? (AS2)

发布于 2024-11-30 19:56:24 字数 217 浏览 6 评论 0原文

我习惯于使用 AS3,但由于最近发生的事件,我需要使用 AS2,并且我在完成一项简单任务时遇到了麻烦:

如何访问 AS 中的 MovieClip? 我画了将其转换为符号(MovieClip 类型)并勾选“导出为 ActionScript”。我给它起了个名字“MyMC”。现在,当我进行其他 MovieClip 操作时,如何访问我之前在舞台上绘制的 MovieClip?

I'm used to working with AS3, but due to recent events I need to work with AS2, and I'm having trouble with a simple task:

How do I access a MovieClip in AS? I drew something, converted it to a symbol (of type MovieClip) and ticked "Export for ActionScript". I gave it the name "MyMC". now, when I'm in some other MovieClips action, how do I access the MovieClip I drew on stage before?

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

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

发布评论

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

评论(1

嘿看小鸭子会跑 2024-12-07 19:56:24

如果它是舞台上的一个对象,您需要使用属性面板为其指定一个实例名称,然后您可以通过 _root 属性访问它:

在此处输入图像描述

_root.myMc.doSomething();

标识符的使用:

告诉库符号导出为动作脚本,其工作方式与在 AS3 中类似。您分配的导出名称是用于使用 attachMovie 函数创建该元件实例的名称:

var myMC:MovieClip = this.attachMovie("instanceName","MyMC",this.getNextHighestDepth());

attachMovie 接受 3 个参数:

  1. instanceName:这就像 AS3 中 DisplayObject 的 name 属性。这是您为创建的符号的每个实例分配的唯一名称。
  2. 库标识符:这是您在创建符号时输入“标识符”字段的名称。
  3. 深度:此影片剪辑在显示树上的深度。您可以定位特定深度,或使用 getNextHighestDepth 将其放置在最高可用深度,与在 AS3 中使用 addChild 相同。

If it's an object on the stage you need to give it an instance name using the properties panel, and then you can access it through the _root property:

enter image description here

_root.myMc.doSomething();

Use of Identifier:

Telling a library symbol to export for actionscript works in a similar way to in AS3. The export name you assign is a name that you use to create an instance of that symbol, using the attachMovie function:

var myMC:MovieClip = this.attachMovie("instanceName","MyMC",this.getNextHighestDepth());

attachMovie accepts 3 parameters:

  1. instanceName: this is like the name property of a DisplayObject in AS3. It is a unique name that you assign to each instance of the symbol you create.
  2. Library Identifier: This is the name that you put into the Identifier field when creating the symbol.
  3. Depth: The depth of this MovieClip on the display tree. You can target a specific depth, or use getNextHighestDepth to place it in the highest available depth, same as using addChild in AS3.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文