Accessing a Clip Inside Another Clip in a Loaded SWF-File
Posted
by Anders
on Stack Overflow
See other posts from Stack Overflow
or by Anders
Published on 2010-03-01T10:14:41Z
Indexed on
2010/05/27
7:41 UTC
Read the original article
Hit count: 251
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);
© Stack Overflow or respective owner