Skip to content
This repository has been archived by the owner on May 15, 2022. It is now read-only.

Shape Export

claus edited this page Aug 13, 2010 · 21 revisions

With as3swf you can export any shape contained in a SWF, including font shapes of embedded fonts, to virtually any other format. You can redraw shapes with Actionscript at runtime, or export source code (e.g. Actionscript, Objective-C, SVG, Degrafa, FXG), or do whatever you feel like doing with it. Reuse your existing Flash vector art on other platforms.


Usage

public function ShapeExport() {
  var request:URLRequest = new URLRequest("any.swf");
  var loader:URLLoader = new URLLoader();
  loader.dataFormat = URLLoaderDataFormat.BINARY;
  loader.addEventListener(Event.COMPLETE, completeHandler);
  loader.load(request);
}
private function completeHandler(e:Event):void {
  var swf:SWF = new SWF(URLLoader(e.target).data as ByteArray);
  var doc:AS3ShapeExporter = new AS3ShapeExporter(swf);
  for (var i:uint = 0; i < swf.tags.length; i++) {
    var tag:ITag = swf.tags[i];
    if (tag is TagDefineShape) {
      TagDefineShape(tag).export(doc);
      trace(doc.actionScript);
    }
  }
}

The export() method expects a SAX-style callback handler instance that implements IShapeExporter. If no such handler is provided, it uses DefaultShapeExporter which does nothing.

Currently available shape exporters are:

- AS3ShapeExporter
- AS3GraphicsDataShapeExporter
- CoreGraphicsShapeExporter
- FXGShapeExporter


Limitations

- bitmap fills not supported yet
- missing convenience methods for bitmap export (to be used in combination with bitmap fills)

I’m working on it.

Clone this wiki locally