Question

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!

Was it helpful?

Solution

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}"/>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top