Extracting an asset from a swf file?

When I create a Flex minigame framework, I plan to bundle a bunch of graphic assets (movie clip symbols) into a single swf file, which I will load into my Flex application before extracting the symbols from the SWF file for use in my application. My question is: How do I do this with actionscript?

Thanks!

+1


a source to share


3 answers


If you don't want to use EMBED and you don't want to load assets at runtime, I recommend exporting the SWF as SWC.

This way you can view SWC files from ActionScript. You can check for events at compile time if a submodel exists in another movie clip.

If you're using the flex compiler, remember to add this when compiling:

-library-path C:\path\to\your\file.swc

      



If you are using FDT, you have the option to automatically add SWC as arguments.

Here's a demo on how to do this with FDT. Not sure which tool you are using. If it's a commercial Flex Builder, the process should be the same.

I think what you are looking for.

+1


a source


I would try to create an AS / A icon / icon library file.

something along the lines

package 
{

public class IconLibrary
{

    /*
    *  Framework Icons
    */

    [Embed (source="../assets/fof_graphics.swf", symbol="clapperboard_icon")]
    public static const clapperBoardIcon:Class;
    [Embed (source="../assets/fof_graphics.swf", symbol="clapperboard_over_icon")]
    public static const clapperBoardOverIcon:Class;
    [Embed (source="../assets/fof_graphics.swf", symbol="close_button")]
    public static const closeButton:Class;
    [Embed (source="../assets/fof_graphics.swf", symbol="close_over")]
    public static const closeOverButton:Class;

    public function IconLibrary()
    {
    }

  }

}

      



Then you only need

source="{IconLibrary.clapperBoardIcon}"

      

or whatever the name of the asset you want to show.

0


a source


Lots of good solutions here, here one, if you are loading swf at runtime and want to retrieve assets, you can do the following in your full event listener listener:

var c:Class = Class(LoaderInfo(e.target).applicationDomain.getDefinition("myClassDefinitionName"));

      

This will store the asset from swf as a class object, so you can instantiate it like this:

var asset:MovieClip = new c();

      

0


a source







All Articles