views:

697

answers:

1

I've reviewed all the documentation and Google results surrounding this and I think I have everything setup correctly. My problem is that the symbol is not appearing in my app. I have a MovieClip symbol that I've embedded to my Flex Component. I need to create a new Image control for each item from my dataProvider and assign this embedded symbol as the Image's source. I thought it was simple but apparently not. Here's a stub of the code:

[Embed(source="../assets/assetLib.swf", symbol="StarMC")]

private var StarClass:Class;

protected function rebuildChildren():void {

    iterator.seek( CursorBookmark.FIRST );

    while ( !iterator.afterLast ) {
     child = new Image();
     var asset:MovieClipAsset = new StarClass() as MovieClipAsset;
     (child as Image).source = asset;

    }
}

I know the child is being created because I can draw a shape and and that appears. Am I doing something wrong? Thank you!

A: 

You should be able to simply set child.source to StarClass:

        child = new Image();
        child.source = StarClass;

See the MovieClipAsset Language Reference for more details:

you rarely need to create MovieClipAsset instances yourself because image-related properties and styles can be set to an image-producing class, and components will create instances as necessary. For example, to set the application background to this animation, you can simply write the following:

  <mx:Application backgroundImage="{backgroundAnimationClass}"/>
jss
Thank you. I've tried that but that doesn't work either. I that reference in the MovieClipAsset documentation before. I've seen that when the Image() are is declared in pure AS - and not in an MXML file that this was the correct syntax. I could be wrong but either way its still not working.
BlueDude
What is in StarMC? You could add asset.gotoAndStop(1); after instantiating asset in your original code to set the movie clip to the first frame which would then be used as the image source.
jss
Its an AS3 MovieClip with a frame-by-frame animation. No ActionScript in the symbol. Nothing I'm doing in ActionScript seems to allow this emmbed symbol to appear. I'm using a couple of other symbols from the swf in another component with no problems.
BlueDude