views:

554

answers:

1

Hi!

I'm creating library swfs in as3 this way, works like a charm (except for the slow mxmlc compiler):

package {
 import flash.display.Sprite; 
 public class Library extends Sprite {
   [Embed(source="assets/test.png")]
      public var TestBitmap:Class; 
 }
}

I would like to create the same kind of libary using swfmill. I've tried the following swmfill simple xml:

<movie version="10">

Examining the libraries in FlashDeveloper's explorer reveals that the as3 library exports BOTH classes and symbols, but the swfmill library exports ONLY symbols. My host application is accessing the as3 library assets this way:

private var loader:Loader = new Loader();

private function onCreationComplete():void {
 this.loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onComplete);
}

private function onComplete(e:Event):void {
 var resourceClass:Class = loader.contentLoaderInfo.applicationDomain.getDefinition("Library") as Class;
 var resources:Object=new resourceClass();
 var testBitmapClass:Class = resources['TestBitmap'] as Class;   
 var testBitmap:Bitmap = new testPngClass();
 this.addChild(testBitmap);
}

But with no exported swfmill classes, there's obviously nothing to instatiate...

Is swfmill expected to export classes this way? If not, is there a way of accessing the symbols without instantiating them as classes?

Jonas

A: 

In short, no. I've been looking into this as well. Since I work with the Flash IDE, haXe, and flex I'll outline the different methods for accessing content by embedding it in a swf.

It doesn't look like there's a way to directly instantiate a symbol. If your assets were exported by the Flash IDE, normally you would set the properties to export for Actionscript to get at the symbol. In haXe you'd specify a class to match that in the swfmill xml. With flex you'd define a class and use the Embed metadata tag to access the symbol by embedding the swf. http://livedocs.adobe.com/flex/3/html/help.html?content=embed%5F4.html

This script which might be helpful to you for generating the export classes. http://wiki.disemia.com/HaXe%5FSWFMILL%5FResource%5FConverter

If you're using AS3, you'll probably have to use mxmlc anyway if you're compiling your project from the command line. Since speed is the issue for you, you should consider using fcsh.

Thanks! Didn't know of fcsh, I'll give it a try. Hopefully the speed difference makes it useful in my production environment... / Jonas
Cambiata