Strengthen compilation in all classes in SWC

Using Flash CS4, I am making a game in which there are a dozen sounds and several music tracks. To reduce publishing / compilation time, I moved the sounds and music to the (external) SWC, which is located in the "Library Path" for the project. This works, but with the caveat ...

Before I injected assets, I dynamically created Sound objects of inline sound, getting their classes with getDefinitionByName .

 // something like... var soundSubClass:Class = Class(getDefinitionByName(soundClassName)); var mySound:Sound = new soundSubClass(); 

But now that they are in an external SWC, I need to have “specific” class references in order to load them like this, otherwise they will not be included in the published SWF and there will be a runtime error when getDefinitionByName tries to get a class that does not exist.

So my question is : in Flash Professional CS4, is there a way to force the inclusion of library resources, regardless of whether they are statically linked?

FlashDevelop has a compiler option "SWC Include Libraries", which is exactly what I want, and differs from the option "SWC Libraries". Description of the "SWC Include Libraries" option: "Associates all classes within the SWC file with the resulting application SWF file, regardless of whether they are used or not."

(In addition, it is important for me that all assets are contained in a single compiled SWF. Runtime linking is not what I need.)

+6
flex flash actionscript-3 swc
source share
5 answers

Unfortunately, I do not think so. I hope this is fixed in CS5, but I would not bet on it ...

The current (aggravating) standard should have a manifest class in your SWC that references all root classes in the rest of the library:

 public class MyLibManifest { public static function manifest():void { var class1:Class = Class1; var class2:Class = Class2; // etc... } } 

Then, somewhere in your main .fla ...

 import com.mylibrary.MyLibManifest; ... var myLibrary:Class = MyLibManifest; 
+4
source share

In Flash CS4 / CS5 there is no way to embed and embed each class in SWC by default, but you can do it with

Flashdevelop

As you already know, these properties of the program project have compiler options that distinguish between:

  • SWC Libraries: "Associates SWC files with the result in the gapplication SWF file. The compiler only refers to these classes for the required SWC file."
  • SWC Include Libraries: "Associates ALL classes within the SWC file with the resulting SWF file of the application, regardless of whether they are used or not.

This second option of “SWC Include Libraries” can be useful because if you just compile FLA as-is into SWC, then put this SWC and other SWC in FlashDevelop as SWC Include Libraries, it should compile / combine them into one SWF which will work the way you want.

FlashDevelop can also just help you create a hard-coded list of classes in SWC, because if you link to SWC as a SWC library, it will appear in the project explorer and you will see a list of all the classes in SWC. You can also right-click on each class and select "Insert into document" and insert the full name of the class. If you do, press the enter key with a semicolon, you will get your first class link. Hover over the list of classes in the project settings and repeat this for each class in the list. Hundreds of classes take only a few minutes, making it easy to create such a list. It would be even faster if the item allowed you to insert more than once, but it doesn’t look like it.

Your only other option that you think you are not interested in for no reason is Runtime Shared Libraries (RSL). It really is not such a big deal to download the file separately, but only if you correctly handle the download process and any errors that may occur. This will add some complexity to your project and may require some additional thought, but I would seriously consider it as an option. See the section “Inheriting Application Domain Names” at www.senocular.com/flash/tutorials/contentdomains/?page=2 for more information .

+3
source share

I'm probably missing something, but isn't it using the -include-libraries and not the path to the compiler library path, this is what the adobe doc says about the option

Associates all classes within the SWC file with the resulting application SWF file, regardless of whether they are used or not.

The contrast of this option is with the "library path" option, which includes only those classes that are referenced at compile time.

Adobe Documentation

I'm new to all of this, so be careful when shooting me with fire :)

+1
source share

You can specify the path to your assets.swc file in ActionScript Properties, and this should work and load assets at runtime.

0
source share

in flex, and whenever you have access to compiler options, you can use: -include YourClass to force the class to be associated with swc, even if it does not reference the main swf.

but I don't know if you can change the compiler options from flash cs4 ...

0
source share

All Articles