访问加载的 SWF 文件中另一个剪辑中的剪辑
我正在用 AS3 编写一个纸牌游戏。与我合作的艺术家(在 Flash CS4 中)制作了一个包含所有卡片图形和动画的 swf 文件。 fla 工作文件的结构如下所示:
- Scene
- CardGraphics (Movie Clip)
- CardFront
- CardBack
- CardValueImage (Movie Clip)
...
在程序中,我创建了 Card 类的 52 个实例,每个实例都有一个从加载的 swf 创建的 MovieClip 实例。这个想法是设置 CardValueImage MovieClip 的框架以对应于 Card 实例的suit 和rank 成员变量。但是,我无法弄清楚如何访问 CardValueImage 并调用 gotoAndStop (或我需要调用的任何方法)。
这基本上就是我想做的:
// Card Class
[Embed(source = 'CardGraphics.swf')]
private static var CardsClip:Class;
private var clip:MovieClip = new CardsClip;
// Card Constructor
this.valueImageFrame = suit * 13 + rank; // Calculate which frame contains the
// graphical representation of this card
this.clip.CardValueImage.gotoAndStop(valueImageFrame);
I'm writing a card game in AS3. The artist I'm working with has produced (in Flash CS4) a single swf-file containing all the card graphics and animations. The structure of the fla working file looks something like this:
- Scene
- CardGraphics (Movie Clip)
- CardFront
- CardBack
- CardValueImage (Movie Clip)
...
In the program I create 52 instances of my Card class, each having a MovieClip instance created from the loaded swf. The idea is to set the frame of the CardValueImage MovieClip to correspond to the Card instance's suit and rank member variables. However, I can't figure out how I access CardValueImage and call gotoAndStop (or whatever method I will need to call).
This is basically what I want to do:
// Card Class
[Embed(source = 'CardGraphics.swf')]
private static var CardsClip:Class;
private var clip:MovieClip = new CardsClip;
// Card Constructor
this.valueImageFrame = suit * 13 + rank; // Calculate which frame contains the
// graphical representation of this card
this.clip.CardValueImage.gotoAndStop(valueImageFrame);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试:
我不确定 CardValueImage 是否是您在 CardGraphics 中的影片剪辑的实例名称,如果是,那么它应该可以工作:)
编辑:
要访问嵌入式 swf 的时间线,您需要不同的方法,留下代码示例和更详细解释它的博客文章。
http://www.8bitrocket.com/newsdisplay.aspx?newspage=36607
*请注意,代码已更改以匹配您的场景。
try:
i'm not sure if CardValueImage is the instance name of the movieclip that you have inside CardGraphics, if it is then it should work :)
EDIT:
to access the timeline of a embedded swf you need a different approach, leave a code example, and a blog post that explains it in more detail.
http://www.8bitrocket.com/newsdisplay.aspx?newspage=36607
*note that the code was changed to match your scenario.
Object(a.contentLoaderInfo.content)
例如,如果您有一个 swf 并且想要访问实例名为
some_name
的元件。Object(a.contentLoaderInfo.content)
For example, if you have a swf and want to access to a symbol with instance name
some_name
.