Hi all,

I'm working on a project with haXe and swfmill targetting Flash 9. So far I'm just importing a few graphics in SVG format, and animating them in code, but I must say that I am already highly impressed by the power and flexibility of swfmill's SVG import -- kudos to all involved.

However, one thing bothers me: the class corresponding to each SVG graphic must explicitly declare an identifier for each top-level node. This is a great feature as far as it goes -- I was not expecting to be able to manipulate individual components within an imported SVG from code. However, it's quite annoying to have to declare identifiers for *every* node, particularly when the identifier is auto-generated by swfmill. For example, for the following trivial SVG:

<svg width='10' height='10'>
   <rect x='0' y='0' width='10' height='10' fill="#ff0000"/>
</svg>

The corresponding haXe class is as follows:

class ExampleRectangle extends Sprite {
   var id7654321 :Sprite; // compulsory, corresponds to rect above

   public function new () {
   }
}

(where id7654321 is an unpredictable name generated by swfmill).


This is improved by giving the rect an id:
...
   <rect id='rectangle' ...
...
   var rectangle :Sprite; // compulsory, but at least predictable
...

but, if the variable is never going to be used, it seems to me to be unnecessarily crufty to be forced to declare it.


The enclosed patch modifies swfmill to not generate a name at all for elements without an explicit id attribute or Inkscape label. I couldn't see any technical reason why generating a name should be necessary, and certainly the patch hasn't broken anything for me so far, but please do let me know if I'm missing something.

If not, could the patch please be applied to svn? (Or at least something like it -- I have less than an hour's experience with XSLT so it's probably unnecessarily messy).


Thanks,
Dan C.
Index: src/xslt/simple-svg.xslt
===================================================================
--- src/xslt/simple-svg.xslt	(revision 240)
+++ src/xslt/simple-svg.xslt	(working copy)
@@ -59,13 +59,17 @@
 				<xsl:value-of select="@id"/>
 			</xsl:when>
 			<xsl:otherwise>
-				<xsl:value-of select="generate-id(.)"/>
+				<xsl:value-of select="''"/>
 			</xsl:otherwise>
 		</xsl:choose>
 	</xsl:variable>
 	<!-- place the object. -->
-	<PlaceObject2 replace="0" depth="{swft:next-depth()}" name="{$name}" 
-objectID="{$id}">
+	<PlaceObject2 replace="0" depth="{swft:next-depth()}" objectID="{$id}">
+		<xsl:if test="$name != ''">
+			<xsl:attribute name="name">
+				<xsl:value-of select="$name"/>
+			</xsl:attribute>
+		</xsl:if>
 		<!-- svg:use elements add an instance transform, all others have it 
 included in their definition. -->
 		<xsl:choose>
_______________________________________________
swfmill mailing list
[email protected]
http://osflash.org/mailman/listinfo/swfmill_osflash.org

Reply via email to