动作脚本和MovieClip - 如何联合多个MovieClip?
我刚刚开始阅读《学习 ActionScript 3.0》这本书。因此,作者在第 3 章中介绍了 EventLinsteners。
有一个副标题“事件传播”。从一开始,作者就在舞台上创建文件夹,实例名称为Folder0 和Folder1,并解释了Mouse_Over 事件。比它说的如果你的舞台上有 100 个这样的文件夹,你就必须为每个文件夹实例编写 EventListener。因此,他们引入了一些“对我来说很奇怪”类型的名为folder_group的实例,它就像1个MovieClip,但里面有几个MovieClip(我猜MovieClip是正确的参考)。
所以,很快,在本章的下一部分中,有一个框架事件小标题,其中作者有 Unicycle。那辆独轮车也是一个单独的 MovieClip。当您双击它时,它必须在其中实例。车身实例和车轮实例。
那么,我到底该怎么做呢?如何创建这样的包含多个不同部分的影片剪辑。当你双击它时,你会从 Scene1 -> 《某个名字》。
请有人解释一下如何做到这一点...我尝试用谷歌搜索但尚未找到线索。
还有一件事。单独的 ActionScript 文件和 FLA-s ActionScript 模式(我的意思是 F9)有什么区别
提前致谢
I just started to read the book Learning ActionScript 3.0. So in the 3rd chapter the author covers EventLinsteners.
There's a sub-heading Event Propagation. From the beginning author creates to Folders on the Stage, with instance names Folder0 and Folder1 and explains Mouse_Over event. Than it says if you have 100 of such folders on your stage you'll have to write EventListener for every Folder instance. So they introduce some "strange for me" type of instance with name folder_group, and it's like 1 MovieClip but with several MovieClips inside (I guess MovieClip is the correct reference).
So, shortly, in the next part of this chapter there's Frame Events sub-heading where Author has Unicycle. That unicycle is a single MovieClip too. It has to instances in it, when you double click it. The body instance and wheel instance.
So, how the hell should I do that. How to create such movieclip that has several different parts in it. When you double click it, you move from Scene1 -> "Some Name".
Please someone, explain how to do that... I tried to google it but to clue yet.
and one more thing. What's the difference between the separate ActionScript file and FLA-s ActionScript mode (I mean F9)
Thanks in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
关于事件传播,您可以查看此链接,示例swf显示冒泡/propagation 并默认停止传播
,点击事件将会传播,因此只要将事件附加到顶级 movieClip 上,就可以在那里设置操作。
你可以尝试这个简单的测试。创建一个名为“mc”的 MovieClip,并在其中放入一些其他影片剪辑,使用此代码,每当您单击该 mc 中的任何内容时,都会触发一个事件。如果您为这些 movieClip 命名,您将看到弹出的名称,否则您应该看到类似“instance#”的名称,
将代码放在 .as 文件中可以使编码变得更加容易。例如,我在外部编辑器中完成 99.7% 的编码,并且仅使用 flash 来创建图形资源。
您可以使用所谓的 documentClass,它扩展了充当舞台的默认 MovieClip,adobe 帮助中的大多数示例都使用这些。为了快速测试,我只使用代码面板(F9)。最大的区别实际上是,以这种方式编码(使用 .as 文件)更容易、更快,特别是使用 FlashDevelop、FlashBuilder、FDT 等 IDE。
doc 类
对于您提供的 fla,您可以将其用于您应该使用的 单击 body 时可看到跟踪的
body
,单击滚轮时可看到跟踪的wheel
regarding event propagation you can look at this link, the example swf shows bubbling/propagation and stoping propagation
by default, the click event will propagate, so as long as you attach the event to the top-level movieClip, you can set the action there.
you can try this simple test. Create a MovieClip with a name "mc" and and put some other movie clips in there, using this code, any time you click on anything that is within that mc, an event will fire. if you name these movieClips, you'll see the names pop up, otherwise you should see names that are something like this "instance#"
having the code in an .as file makes it a lot easier to code. For example I do 99.7% of the coding in an external editor, and only use flash to create my graphic resources.
You can use what's called a documentClass, which extends the default MovieClip that acts as the stage, most examples in adobe help are using these. For quick tests I just use the code panel(F9). The big difference really is that coding this way (using .as files) is a lot easier and faster, especially with an IDE like FlashDevelop, FlashBuilder, FDT etc.
for the fla you provided, you could use this for the doc class
you should see
body
traced when you click on the body, andwheel
when you click on wheel