Can't access media assets in an SWC

1.5k views Asked by At

I'm having trouble accessing content in an SWC. The main project compiles without error, but the assets (sound, music) aren't displayed or played.

My workflow:

i. Using Flash CS5
1. Create MAsset.fla
2. Import sounds, art
3. Assign class names, check export in frame 1
4a. Write out the classes in the actions panel in frame 1
4b. OR. Add a document class and write out the classes there
5. Export SWC. Filesize is similar to what it is when I directly import assets in the main project library.
6. Create Project.fla and document class Project.as
7. Import SWC into main project through the Actionscript panel.
8. Add code, which calls the class names from the SWC (e.g. DCL_UI_MOUSE)
9. Compile.

No compiler errors, but nothing doing. And the resulting SWF filesize doesn't reflect anything more than the compiled code from the main project.

Regarding step 4, if I just write the class name in the root timeline or document class, the compiler error will go away and the asset appear to be compiled in the SWC. But I have also tried:

var asset0000:DCL_UI_MOUSE;

And:

var asset0000:DCL_UI_MOUSE = new DCL_UI_MOUSE();

Regardless the assets don't make it into the final SWF.

What am I doing wrong?

1

There are 1 answers

0
weltraumpirat On BEST ANSWER

What exactly do you mean when you say "Import SWC into the main project through the ActionScript panel" and "Add code, which calls the class names from the SWC"?

If you want to use an SWC as an asset library, you have to

  1. add the SWC to the library path, and
  2. always add the appropriate import statements to your ActionScript code.

There's no step threeâ„¢.

You can also use it as a runtime shared library by linking to individual library objects in the properties panel.

To get your library items to compile into the the SWC, check "export for ActionScript" and "export in frame 1", then write your fully qualified class name into the "class" field. "Base class" should be set to flash.display.MovieClip or flash.display.Sprite (for MovieClip items), or flash.display.SimpleButton (for Button items)- whichever fits the object best.

Also, note that it is customary to use camel case for class names (eg: DclUIMouse). The all caps DCL_UI_MOUSE would be used when naming a constant.