Skip to content
Permalink
Browse files
Now, the WriteFXG tool can optimize FXG files before saving them. i.e…
…. remove unwanted nested Groups created by Adobe Illustrator, Fireworks, etc.
  • Loading branch information
bigosmallm committed Oct 16, 2013
1 parent 41cd30e commit 73f9a633896816049e7b7d9cb3a963fcd433b69e
Showing 1 changed file with 44 additions and 25 deletions.
@@ -1,20 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<s:WindowedApplication xmlns:fx="http://ns.adobe.com/mxml/2009"
@@ -93,11 +93,11 @@
private function makeFXGFiles():void
{
default xml namespace = fxgns;
var topGroups:XMLList = sourceXML.Group;
/*var topGroups:XMLList = sourceXML.Group;
if (topGroups.length() > 1)
errorLabel.text = "Unexpected: More than one top-level group";
errorLabel.text = "Unexpected: More than one top-level group";
topTags = topGroups.children();
numTags = topTags.length();
numTags = topTags.length();*/
var syms:XMLList = sourceXML.Library.children();
var n:int = syms.length();
@@ -127,8 +127,8 @@
private function getNewFXG(v:XML):XML
{
var childFXG:XML = optimizeFXG(v.copy());
var newFXG:XML = v.copy();
//var newFXG:XML = new XML();
var newName:String = newFXG.@name
// change name from 'Definition' to 'Graphic'
newFXG.setName("Graphic");
@@ -139,17 +139,36 @@
// add version
newFXG.@version = "2.0";
for (var i:int=newFXG.children().length(); i>=0; i--)
{
delete newFXG.child(i)[0];
}
newFXG.setChildren(childFXG);
//newFXG.removeNamespace("aaa");
return newFXG;
}
private function optimizeFXG():void
/*private function optimizeFXG():void
{
readFile();
optimize();
readFile();
optimize();
}*/
private function optimizeFXG(v:XML):XML
{
var children:XMLList = v.children();
var outputXML:XML;
if(children.length() == 1)
{
outputXML = simplify(children[0]);
}
else
{
for each (var child:XML in children)
{
if(child.localName() != "Private")
{
outputXML.appendChild(simplify(child));
}
}
}
return outputXML;
}
private function optimize():void{
@@ -206,8 +225,8 @@
<s:Button label="Browse..." click="browse()" />
</s:HGroup>
<s:HGroup width="100%">
<s:Button label="Write Library to FXGs" click="writeFXG()" />
<s:Button label="Optimize FXG" click="optimizeFXG()" />
<s:Button label="Create and optimize FXG symbols" click="writeFXG()" />
<!--<s:Button label="Optimize FXG" click="optimizeFXG()" />-->
</s:HGroup>
<s:Label id="errorLabel" />
</s:VGroup>

0 comments on commit 73f9a63

Please sign in to comment.