Updated Branches:
  refs/heads/develop 58c11da06 -> 73f9a6338

Now, the WriteFXG tool can optimize FXG files before saving them.  i.e. remove 
unwanted nested Groups created by Adobe Illustrator, Fireworks, etc.


Project: http://git-wip-us.apache.org/repos/asf/flex-utilities/repo
Commit: http://git-wip-us.apache.org/repos/asf/flex-utilities/commit/73f9a633
Tree: http://git-wip-us.apache.org/repos/asf/flex-utilities/tree/73f9a633
Diff: http://git-wip-us.apache.org/repos/asf/flex-utilities/diff/73f9a633

Branch: refs/heads/develop
Commit: 73f9a633896816049e7b7d9cb3a963fcd433b69e
Parents: 41cd30e
Author: Om <[email protected]>
Authored: Wed Oct 16 11:37:09 2013 -0700
Committer: Om <[email protected]>
Committed: Wed Oct 16 11:38:26 2013 -0700

----------------------------------------------------------------------
 FXGTools/src/WriteFXG.mxml | 69 ++++++++++++++++++++++++++---------------
 1 file changed, 44 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/flex-utilities/blob/73f9a633/FXGTools/src/WriteFXG.mxml
----------------------------------------------------------------------
diff --git a/FXGTools/src/WriteFXG.mxml b/FXGTools/src/WriteFXG.mxml
index 621e6e2..4addc7c 100644
--- a/FXGTools/src/WriteFXG.mxml
+++ b/FXGTools/src/WriteFXG.mxml
@@ -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>

Reply via email to