Take the 2-minute tour ×

I am making an AS3 project in FB4. In our workflow, we have artists compile art into SWC files which the I then link as 'Referenced Libraries' in FB4.

Then I set the "Link Type" of the SWC files to "external" instead of merged into code. This should create SWFs corresponding to the SWC files in the output folder, right?

This doesn't seem to be the case. I am only seeing one SWF file: the main_app's.

I was trying to make it so that I can use a library manager to load the files dynamically.

I tried extracting the swfs manually, but it seems the main_app still compiles all the swcs to itself. I made sure the Link Type was set to external. The file size for the main_app between "external" and "merged to code" seem to be the same.

share|improve this question
add comment

2 Answers

up vote 1 down vote accepted

I've made a simple project in Flash Builder 4 and the only way I got the SWC->SWF happening is by creating a Flex Project instead of an ActionScript Project and selecting "Runtime shared library (RSL)" instead of "External". This is because the Flex framework have some classes that work out the loading of those libraries for you. It also automate the conversion (I should say extraction) process.

Now, if you don't want to create a Flex project just for this, you can extract the SWF yourself. The SWC file format is just a Zip containing a SWF and an XML file describing the content. You can then load dynamically this extracted SWF file using a Loader and setting the correct Application Domain. Here's a snippet of my sample project.

public class Web extends Sprite
    public function Web()
        //you will not be able to instantiate classes of your library until it's loaded
        var loader:Loader = new Loader();
        loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onLoadComplete);
        loader.load(new URLRequest("library.swf"), new LoaderContext(false, ApplicationDomain.currentDomain));

    protected function onLoadComplete(event:Event):void
        //here you can create instances of classes defined in your library
        new Asset();


You might think that's a pretty tedious job to unzip+copy every time your designers update the library. You could automate this process with a script or an Ant file. Unfortunately, unless I'm missing something, it looks like Flash Builder doesn't want you to extend your build process, so you will still need a bit of hand work or completely convert to Ant (or something similar) to build.

Good luck!

share|improve this answer
Alternatively, one can load swc file into bytearray, extract swf from it with some zip library and load it into said ApplicationDomain - all in actionscript. –  alxx Nov 14 '10 at 8:55
@alxx Good idea. I'm gonna try that. –  subb Nov 15 '10 at 1:21
add comment

From the moment the SWC is added to your Library, you should be able to access the SWC's assets by directly calling their specific class names . There's no need to try to get a SWF and load it with the Loader class. This actually defeats the purpose of using a SWC in the first place!

Let's say that , in your SWC, you have a MovieClip with a class name of GraphicAsset, to create a new instance , you simply do this:

  var mc:MovieClip = new GraphicAsset();

In FB4's folder structure , have a look at your SWC in the Referenced Libraries folder & check the default package, you should see a list of all your assets.

share|improve this answer
I think you misunderstood the op. He wants to load assets dynamically and not compile them with its application. –  subb Nov 15 '10 at 1:19
add comment

Your Answer


