SWC files compiled from ActionScript library projects in Flex Builder aren't usable in Flash. But if you're really stubborn and crazy enough, you can make it work.
Primary condition however, is that you can't use any classes in your ActionScript library project that have dependencies in the Flex component framework. But stuff like making the ArrayCollection class work in Flash is doable, for example. And much more off course.
Firstly, take your SWC file and copy-paste this file into the "Components" folder under the "First Run" folder of your Flash CS3 installation (ex. C:\Program Files\Adobe\Adobe Flash CS3\en\First Run\Components). Then restart Flash CS3 and open the components panel where you should be able to find the newly added code library. Drag the "component(s)" to the stage to have them added in your library (and then you can delete them from the stage). All this "component action" will enable the Flash compiler to perform type-checking when you instantiate and use classes from your ActionScript library project. This means that the FLA file will compile but the execution will still fail at runtime because the classes in question aren't added into your SWF (yet).
To get the classes inside your SWF, just create an SWF class library and load that SWF library into the same ApplicationDomain.
You can create an SWF library using mxmlc (in your Flex SDK) on the command line. First create a single class in which you make references to all the classes you need to be included into your SWF library, for example:
package
{
import flash.display.Sprite;
public class MySWFLibrary extends Sprite
{
import be.oneagency.musicplayer.vo.*;
public function MySWFLibrary()
{
be.oneagency.musicplayer.vo.Artist;
be.oneagency.musicplayer.vo.MusicCollection;
be.oneagency.musicplayer.vo.Playlist;
be.oneagency.musicplayer.vo.Song;
be.oneagency.musicplayer.vo.UserConfiguration;
}
}
}
How to create .swf-Base Class Library in Flex Builder is very well explained in chapter 31 of Colin Moock's "Essential ActionScript 3.0" (you gotta own the Moock book).
What it comes down to is that you need to do something like this on the command line:
cd C:\Program Files\Adobe\Flex Builder 3\sdks\3.0.0\bin
mxmlc path_to_project\src\MySWFLibrary.as -output path_to_project\bin\MySWFLibrary.swf
Then, before doing anything in Flash, you first need to load the SWF library in the same ApplicationDomain like this:
var libLoader:Loader = new Loader();
libLoader.contentLoaderInfo.addEventListener(Event.INIT, libraryInitListener);
libLoader.load(new URLRequest("MySWFLibrary.swf"), new LoaderContext(false, ApplicationDomain.currentDomain));
As soon as the libraryInitListener method is called, you can start using the classes from your library.
[UPDATE March 2009]:
since Flash CS4 you can directly use a Flex library SWC in Flash, check out this demo by Serge: http://www.webkitchen.be/2009/03/09/video-tutorial-use-flex-for-your-actionscript-coding-for-flash-cs4/

