我可以同时控制加载的 swf 中影片剪辑的多个实例吗?
我正在通过加载器类将在 flash professional cs5 中创建的 swf 加载到 Flex 4.1 应用程序中。 Flash 文件包含为动作脚本导出的多个影片剪辑,并且这些影片剪辑存在于整个电影的许多实例中。
迭代所有内容,比较类类型似乎是解决这个问题最简单但也是最冗余的方法。有没有办法使用类名作为一种全局选择器来访问剪辑?
我还可以让 Flash 中的子剪辑侦听它们执行操作的事件,但我不太确定什么是最好的。
I am loading an swf created in flash professional cs5 via the loader class into a flex 4.1 application. The flash file contains multiple movieclips that are exported for actionscript and those movieclips exist in many instances throughout the movie.
Iterating through everything, comparing class types seems to be the most easy but also the most redundant way to solve this. Is there any way of using the class name as a kind of global selector to access the clips?
I could also make the sub-clips in the flash listen for an event on which they perform an action, but I am not really sure what might be best.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在这种情况下,我发现解决问题的一个好方法是创建一个可静态访问的类,该类管理在实例化时向其注册的其他类的实例。举个例子...
并且...
GloballyStoppableMovieClip 的任何和所有实例都会立即向 GlobalStopper 注册,因此调用
...将停止所有已注册的影片剪辑。
您可以添加任何您想要的其他功能。此外,您可以让它接受实现您的 movieclip 子类(或也可能需要停止和播放的非 movieclip 对象!)的公共函数 stop() 和 play() 的 Istoppable 或 IPlayable 对象,而不是添加接受 MovieClip 实例!然后实施。
但对于类似 jQuery 的选择器呢?这并不是我处理这个特定问题的方式。
In cases like these, I find that a good way to solve the problem is to create a statically accessable class that manages instances of other classes that are registered with it on instantiation. As an example...
and...
Any and all instances of GloballyStoppableMovieClip are instantly registered with the GlobalStopper, so calling
...will stop all registered movieclips.
You can add in any other functions you want. Furthermore, instead of having add accept MovieClip instances, you could have it accept IStoppable or IPlayable objects that implement public functions stop() and play() that your movieclip subclass (or non-movieclip object that also might need to stop and play!) then implements.
But as for jQuery-like selectors? Not really the way I'd handle this particular issue.
我想把它打出来就可以了。我使用了事件解决方案:
在根时间轴中我放置了一个这样的函数:
在库剪辑的主时间轴中是:
这很脏,但你明白了。
i guess typing it out did the trick. i used the event solution:
in the root timeline i placed a function like this:
and in the library clip's main timeline goes:
this is dirty but you get the idea.