<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="100%" height="100%"
xmlns:ns1="*" backgroundColor="#F3F3F3" viewSourceURL="srcview/index.html">
<fx:Script>
<![CDATA[
import flash.desktop.Clipboard;
import flash.desktop.ClipboardFormats;
import spark.effects.Fade;
private var fxgString:String;
protected function button1_clickHandler(event:MouseEvent):void
{
fxgString=ta1.text;
ta1.text= convertFXGtoMXMLG(ta1.text);
if(clipboardCB.selected) Clipboard.generalClipboard.setData(ClipboardFormats.TEXT_FORMAT, ta1.text);
}
private function convertFXGtoMXMLG(pFxg:String):String
{
var text:String=pFxg;
text=text.replace('<?xml version="1.0" encoding="utf-8" ?>', "");
text=text.replace('xmlns="http://ns.adobe.com/fxg/2008"', "");
text=text.replace( /<Private\/>/g, "");
text=text.replace( /<Private.*<\/Private>/gs, "");
text=text.replace( /<\//g, "</s:");
text=text.replace( /<(?!\/s:)/g, "<s:");
text=text.replace( /<s:Library\/>/g, "");
text=text.replace( /<s:Library>/g, "<fx:Library>");
text=text.replace( /<\/s:Library>/g, "</fx:Library>");
text=text.replace( /<s:Definition/g, "<fx:Definition");
text=text.replace( /<\/s:Definition>/g, "</fx:Definition>");
var libraryString:String="";
var result:Array = text.match( /<fx:Library.*<\/fx:Library>/gs);
if(result!=null && result[0]!=null)
{
libraryString=result[0];
text=text.replace( /<fx:Library.*<\/fx:Library>/gs, "");
text=libraryString+text+"\n";
}
text=text.replace( /ai:\w+=\"[^\"]+\"/g, "");
text=text.replace( /flm:\w+=\"[^\"]+\"/g, "");
text=text.replace( /ATE:\w+=\"[^\"]+\"/g, "");
text=text.replace( /pd:\w+=\"[^\"]+\"/g, "");
text=text.replace( /d:\w+=\"[^\"]+\"/g, "");
text=text.replace(/(?:alpha=\"1\")/g, ""); text=text.replace(/(?:blendMode=\"normal\")/g, ""); text=text.replace(/(?:winding=\"evenOdd\")/g, ""); text=text.replace(/(?:weight=\"1\")/g, ""); text=text.replace(/(?:caps=\"round\")/g, "");
var defResult:Array = text.match( /<fx:Definition\sname=\"\w+/g);
for ( var i:int=0; i < defResult.length ; i++)
{
var defline:String=defResult[i];
var defName:String=defline.split('"')[1];
var regxp:RegExp = new RegExp("s:"+defName, "gi");
text=text.replace(regxp, "fx:"+defName);
}
return text;
}
]]>
</fx:Script>
<fx:Declarations>
</fx:Declarations>
<s:layout>
<s:VerticalLayout horizontalAlign="center"
paddingLeft="100" paddingRight="100" paddingBottom="100"
paddingTop="50"/>
</s:layout>
<s:Label x="10" y="10" text="FXG to MXML Graphics converter" fontSize="24" fontWeight="bold" fontFamily="Georgia" color="#565656"/>
<s:RichEditableText
id="ta1"
width="100%" height="100%"
paddingLeft="5" paddingRight="5" paddingBottom="5" paddingTop="5"
text="Paste your FXG content here"
backgroundColor="0xffffff" focusThickness="1"
focusIn="{dsf.color = 0x70B2EE; dsf.alpha = 1;}" focusOut="{dsf.color = 0; dsf.alpha = 0.3}">
<s:filters>
<s:DropShadowFilter id="dsf" alpha="0.3" blurX="5" blurY="5" quality="3" distance="1" angle="90"/>
</s:filters>
</s:RichEditableText>
<s:CheckBox label="Copy to Clipboard" selected="true"
id="clipboardCB"/>
<s:Button x="204" y="365" label="Convert to MXML Graphics"
click="button1_clickHandler(event)" height="38"/>
</s:Application>