Apache – how to use UIComponent/Flash in Flex

apache-flexcomponentsflashflex3

I am new to Flash/Flex.
I would like to use a Component I created in Flash extending fl.core.UIComponent. How do I use this in Flex? Do I just export it as a swc or do I have to use the Flash Flex 3 kit which will convert it to a UIMovieClip. That does not sound right.

I would appreciate a few simple steps describing the process.
Thanks
Sanoran

Best Answer

You can publish your file as a .swf and use the SWFLoader to load it, just remember the paths are relative to your run/debug directories.

My understanding is swc files are generally library files, rather than visual components, because you want the libraries included at compile time (swc) rather than at runtime (swf).

        var loader = new SWFLoader();

         // set autoload to false just so we KNOW when it loads. Also prevents
         // us from accidently loading it twice by calling load() later
         loader.autoLoad = false;
         loader.addEventListener(Event.INIT, function (nt:Event) {
             // Remove event listener so can be garbage collected
             event.currentTarget.removeEventListener(event.type, arguments.callee);  
             // note we can the loader, rather than
             // loader.content
             someIVisualElementContainer.addElement(loader);

         });

         // relative to bin-debug or bin-release
         loader.source = "movie.swf";

        loader.load();