flash - How To Convert a SWF / DisplayObject to SVG data? -


anything out there can transform swf or displayobject svg?

im trying find way generate large sized jpg swf/vector shape. current jpg export() as3 has limits jpg size , resolution.

so figured can send svg data imagemagick.

thanks!

artur

if it's complex swf, might need decompile using proper tool , import vector assets , convert/re save them svg.

if it's shapes (no bitmaps/shapes), can use awesome as3swf library , it's svghapeexporter.

here's quick class:

package {     import com.bit101.components.*;     import com.codeazur.as3swf.*;     import com.codeazur.as3swf.exporters.svgshapeexporter;     import com.codeazur.as3swf.tags.*;     import com.codeazur.as3swf.tags.*;      import flash.display.*;     import flash.events.*;     import flash.net.*;     import flash.utils.*;       public class swf2svg extends sprite {          private var swffile:filereference;         private var svgfile:filereference;         private var status:label;         private var load : pushbutton;         private var save : pushbutton;         private var svg:xml;         private var filename : string;          public function swf2svg() {             init();         }         private function init():void{             stage.align = stagealign.top_left;             stage.scalemode = stagescalemode.no_scale;             drawgui();         }         private function drawgui() : void {             var vbox:vbox = new vbox(this);             var buttons:hbox = new hbox(vbox);             load = new pushbutton(buttons,0,0,"load swf",selectswf);             save = new pushbutton(buttons,0,0,"save svg",selectsvg);save.enabled = false;             status = new label(buttons,0,0,'load swf file');         }         private function selectswf(event:mouseevent):void{             swffile = new filereference();             swffile.addeventlistener(event.select,swfselected);             swffile.addeventlistener(event.complete,swfloaded);             swffile.browse([new filefilter("swf file (*.swf)", "*.swf")]);         }         private function selectsvg(event:mouseevent):void{             svgfile = new filereference();             var bytes:bytearray = new bytearray();             bytes.writeutfbytes(svg);             svgfile.save(bytes,filename.replace('.swf','.svg'));         }         private function swfselected(event:event):void{             swffile.load();             filename = swffile.name;             save.enabled = false;         }         private function swfloaded(event:event):void{             var bytes:bytearray = swffile.data;             var swf:swf = new swf(bytes);             var svgexporter:svgshapeexporter = new svgshapeexporter(swf);             (var i:uint = 0; < swf.tags.length; i++) {                 var tag:itag = swf.tags[i];                 if (tag tagdefineshape) tagdefineshape(tag).export(svgexporter);             }             svg = svgexporter.svg;             if(svg != null){                 status.text = "ready! save svg file";                 save.enabled = true;             }else status.text = "no shapes export found";         }      }  } 

you can run here.

swf2svg preview


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -