Index: com/zavoo/svg/SVGViewer.as
===================================================================
--- com/zavoo/svg/SVGViewer.as	(revision 47)
+++ com/zavoo/svg/SVGViewer.as	(working copy)
@@ -1,3 +1,4 @@
+
 /*
 Copyright (c) 2008 James Hight
 
@@ -24,8 +25,10 @@
 */
 
 package com.zavoo.svg {
+	import com.zavoo.svg.data.SVGColors;
 	import com.zavoo.svg.events.SVGEvent;
 	import com.zavoo.svg.nodes.SVGRoot;
+	import com.zavoo.svg.nodes.SVGNode;
 	
 	import flash.display.Bitmap;
 	import flash.display.BitmapData;
@@ -34,6 +37,7 @@
 	import flash.events.Event;
 	import flash.events.IOErrorEvent;
 	import flash.events.ProgressEvent;
+	import flash.external.ExternalInterface;
 	import flash.net.URLLoader;
 	import flash.net.URLLoaderDataFormat;
 	import flash.net.URLRequest;
@@ -56,7 +60,7 @@
 			
 			super();
 			
-			svgRoot = new SVGRoot();
+			svgRoot = new SVGRoot(this);
 			
 			this.addChild(svgRoot);
 						
@@ -102,6 +106,47 @@
 			return svgRoot.xml;
 		}
 		
+		public function getAttribute(nodeID:String, attribute:String):String {
+			var elem:* = null;
+			if (this.svgRoot.xml.@id == nodeID) {
+				elem = this.svgRoot;
+			}
+			else {
+				elem = this.svgRoot.getElement(nodeID);
+			}
+			
+			if (elem == null) {
+				return null;
+			}
+			
+			return elem.getAttribute(attribute);
+		}
+		
+		public function setAttribute(nodeID:String, attribute:String,
+																	attrValue:String):void {																		
+			var elem:* = null;
+			if (this.svgRoot.xml.@id == nodeID) {
+				elem = this.svgRoot;
+			}
+			else {
+				elem = this.svgRoot.getElement(nodeID);
+			}
+			
+			if (elem != null) {
+				elem.setAttribute(attribute, attrValue);
+			}
+		}
+		
+		public function appendDomChild(xmlStr:String, parentId:String):void {
+			var node:SVGNode = this.svgRoot.getElement(parentId);
+			var xml:XML = new XML(xmlStr);
+			node.appendDomChild(xml, parentId);
+		}
+		
+		public static function debug(msg){
+			ExternalInterface.call('__svg__debug', msg);
+		}
+
 		private function onComplete(event:Event):void {
 			this.dispatchEvent(event.clone());
 			var byteArray:ByteArray = ByteArray(_urlLoader.data);
@@ -164,11 +209,11 @@
 			super.width = svgRoot.width;
 			super.height = svgRoot.height;
 			
-			this.graphics.clear();
 			if (this._backgroundColor >= 0) {
+				this.graphics.clear();
 				this.graphics.beginFill(this._backgroundColor);
 				this.graphics.drawRect(0, 0, svgRoot.width, svgRoot.height);
-				this.graphics.endFill(); 
+				this.graphics.endFill();
 			}
 		}
 			
Index: com/zavoo/svg/nodes/SVGGroupNode.as
===================================================================
--- com/zavoo/svg/nodes/SVGGroupNode.as	(revision 47)
+++ com/zavoo/svg/nodes/SVGGroupNode.as	(working copy)
@@ -23,18 +23,16 @@
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-package com.zavoo.svg.nodes
-{
-	import mx.controls.TextArea;
-	import mx.utils.StringUtil;
-	
-	/**
-	 * Acts as a container for other nodes
-	 **/
-	public class SVGGroupNode extends SVGNode
-	{
-		public function SVGGroupNode(xml:XML):void {
-			super(xml);
-		}	
-	}
+package com.zavoo.svg.nodes
+{
+	
+	/**
+	 * Acts as a container for other nodes
+	 **/
+	public class SVGGroupNode extends SVGNode
+	{
+		public function SVGGroupNode(xml:XML):void {
+			super(xml);
+		}
+	}
 }
Index: com/zavoo/svg/nodes/SVGRoot.as
===================================================================
--- com/zavoo/svg/nodes/SVGRoot.as	(revision 47)
+++ com/zavoo/svg/nodes/SVGRoot.as	(working copy)
@@ -1,30 +1,31 @@
-/*
-Copyright (c) 2008 James Hight
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
+/*
+Copyright (c) 2008 James Hight
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+*/
+
 package com.zavoo.svg.nodes
 {
+	import com.zavoo.svg.SVGViewer;
 	import com.zavoo.svg.data.SVGColors;
 	import com.zavoo.svg.events.SVGEvent;
 	import com.zavoo.svg.events.SVGUIEvent;
@@ -54,17 +55,21 @@
 		private var _loadTime:int;
 		
 		private var _width:Number;
-		private var _height:Number;
-		
-		/**
-		 * Used to track number of nodes that need to be rendered
-		 **/
-		private var _invalidNodeCount:uint = 0;
-		
+		private var _height:Number;
+		
+		private var _svgViewer:SVGViewer;
+		
+		/**
+		 * Used to track number of nodes that need to be rendered
+		 **/
+		private var _invalidNodeCount:uint = 0;
+		public var totalNodeCount:uint = 0;
+		
 		private var _currentNode:SVGNode = null;
 				
-		public function SVGRoot(xml:XML = null):void {
-			super(XML(xml));
+		public function SVGRoot(svgViewer:SVGViewer, xml:XML = null):void {
+			super(XML(xml));
+			this._svgViewer = svgViewer;
 			this.addEventListener(Event.REMOVED, onRemoved);
 		}	
 		
@@ -83,25 +88,25 @@
 		 **/
 		public function get scale():Number {
 			return this.scaleX;
-		}
-		
-		/**
-		 * @private
-		 **/
-		override public function set scaleX(value:Number):void {
-			super.scaleX = value;
+		}
+		
+		/**
+		 * @private
+		 **/
+		override public function set scaleX(value:Number):void {
+			super.scaleX = value;
 			this.dispatchEvent(new Event(Event.RESIZE));
-		}
-		
-		/**
-		 * @private
-		 **/
-		override public function set scaleY(value:Number):void {
-			super.scaleY = value;
-			this.dispatchEvent(new Event(Event.RESIZE));
-		}
+		}
 		
+		/**
+		 * @private
+		 **/
+		override public function set scaleY(value:Number):void {
+			super.scaleY = value;
+			this.dispatchEvent(new Event(Event.RESIZE));
+		}
 		
+		
 		/**
 		 * Set super._xml
 		 * Create new _elementById object
@@ -132,6 +137,17 @@
 				this._elementById[id] = node;
 			}			
 		}
+
+		/**
+		 * Unregisters a node
+		 * 
+		 * @param id id to unregister
+		 **/
+		public function unregisterElement(id:String):void {
+			if (this._elementById[id] != undefined) {
+				delete this._elementById[id];
+			}			
+		}
 		
 		/**
 		 * Retrieve registered node by name
@@ -207,6 +223,13 @@
 					this.addRootMask(0, 0, this._width, this._height);
 				}
 			}
+			
+			//Set the background color of the canvas
+			var bgColor = this.getStyle('background-color');
+			if (bgColor != null) {
+				bgColor = SVGColors.getColor(bgColor);
+				this._svgViewer.backgroundColor = bgColor;
+			}
 		}		
 		
 		/**
@@ -227,9 +250,9 @@
 				Shape(this.mask).graphics.drawRect(xVal, yVal, widthVal, heightVal);
 				Shape(this.mask).graphics.endFill();
 			}
-		}
-		
-		private function onRemoved(event:Event):void {
+		}
+		
+		private function onRemoved(event:Event):void {
 			this.dispatchEvent(new SVGEvent(SVGEvent.SVG_UNLOAD));
 		}
 		
@@ -285,39 +308,40 @@
 		 **/
 		override public function set height(value:Number):void {
 			//Do nothing
-		}
-		
-		override protected function setupEvents():void {
-			//Do nothing
-		}
-		
-		
-		public function set invalidNodeCount(value:int):void {
-			/* if (value < 0) {
-				trace('Something is wrong with the invalid node counter! It has a value of ' + value.toString() + '!');
-			} */
-			this._invalidNodeCount = value;
-			if (value == 0) {
+		}
+		
+		override protected function setupEvents():void {
+			//Do nothing
+		}
+		
+		
+		public function set invalidNodeCount(value:int):void {
+			/* if (value < 0) {
+				trace('Something is wrong with the invalid node counter! It has a value of ' + value.toString() + '!');
+			} */
+			this._invalidNodeCount = value;
+			if (value == 0) {
 				this.dispatchEvent(new SVGEvent(SVGEvent.SVG_LOAD));
+				this._invalidNodeCount = this.totalNodeCount;
 			}
-		}
-		
-		public function get invalidNodeCount():int {
-			return this._invalidNodeCount;
-		}		
-		
-		public function set currentNode(node:SVGNode):void {
-			if (this._currentNode != null) {
-				this.dispatchEvent(new SVGUIEvent(this._currentNode, SVGUIEvent.FOCUS_OUT));
-			}
-			this._currentNode = node;
-			this.dispatchEvent(new SVGUIEvent(this._currentNode, SVGUIEvent.FOCUS_IN));
+		}
+		
+		public function get invalidNodeCount():int {
+			return this._invalidNodeCount;
+		}		
+		
+		public function set currentNode(node:SVGNode):void {
+			if (this._currentNode != null) {
+				this.dispatchEvent(new SVGUIEvent(this._currentNode, SVGUIEvent.FOCUS_OUT));
+			}
+			this._currentNode = node;
+			this.dispatchEvent(new SVGUIEvent(this._currentNode, SVGUIEvent.FOCUS_IN));
 			this.dispatchEvent(new SVGUIEvent(this._currentNode, SVGUIEvent.ACTIVATE));
-		}
-		
-		public function get currentNode():SVGNode {
+		}
+		
+		public function get currentNode():SVGNode {
 			return this._currentNode;
 		}
 		
 	}
-}
+}
Index: com/zavoo/svg/nodes/SVGNode.as
===================================================================
--- com/zavoo/svg/nodes/SVGNode.as	(revision 47)
+++ com/zavoo/svg/nodes/SVGNode.as	(working copy)
@@ -24,22 +24,25 @@
 */
 
 package com.zavoo.svg.nodes
-{
-	import com.zavoo.svg.data.SVGColors;
-	import com.zavoo.svg.events.SVGMouseEvent;
-	import com.zavoo.svg.events.SVGMutationEvent;
-	import com.zavoo.svg.nodes.fills.SVGGradientFill;
-	import com.zavoo.svg.nodes.mask.SVGMask;
-	
-	import flash.display.CapsStyle;
-	import flash.display.DisplayObject;
-	import flash.display.JointStyle;
-	import flash.display.LineScaleMode;
-	import flash.display.Sprite;
-	import flash.events.Event;
-	import flash.events.MouseEvent;
-	import flash.geom.Matrix;
-	
+{
+	import com.zavoo.svg.SVGViewer;
+	import com.zavoo.svg.data.SVGColors;
+	import com.zavoo.svg.events.SVGEvent;
+	import com.zavoo.svg.events.SVGMouseEvent;
+	import com.zavoo.svg.events.SVGMutationEvent;
+	import com.zavoo.svg.nodes.fills.SVGGradientFill;
+	import com.zavoo.svg.nodes.mask.SVGMask;
+	
+	import flash.display.CapsStyle;
+	import flash.display.DisplayObject;
+	import flash.display.JointStyle;
+	import flash.display.LineScaleMode;
+	import flash.display.Sprite;
+	import flash.events.Event;
+	import flash.events.MouseEvent;
+	import flash.geom.Matrix;
+	import flash.utils.*;
+	
 	import mx.utils.StringUtil;
 		
 	/** Base node extended by all other SVG Nodes **/
@@ -105,8 +108,13 @@
 		protected var _invalidDisplay:Boolean = false;
 		
 		protected var _firstRendering:Boolean = true;
-				
+
 		/**
+		 * The ID of this node. Used so we can detect if the ID has changed.
+		 */
+		protected var _id:String = null;			
+	
+		/**
 		 * Constructor
 		 *
 		 * @param xml XML object containing the SVG document. @default null	
@@ -136,7 +144,19 @@
 		protected function setAttributes():void {			
 			
 			var xmlList:XMLList;
+
+			//Unregister and re-register the node's ID if it has changed
+			var newID = this._xml.@id;
+			if (newID == '' || newID == null || newID == undefined) {
+				newID = null;
+			}
 			
+			if (newID != null && newID != this._id) {
+				this.svgRoot.unregisterElement(this._id);
+				this._id = newID;
+				this.svgRoot.registerElement(this._id, this);
+			}
+			
 			this._style = new Object();
 			
 			//Get styling from XML attribute list
@@ -213,9 +233,7 @@
 		 * Perform transformations defined by the transform attribute 
 		 **/
 		protected function transformNode():void {
-			
 			var trans:String = this.getAttribute('transform');
-			
 			if (trans != null) {
 				var transArray:Array = trans.match(/\S+\(.*?\)/sg);
 				for each(var tran:String in transArray) {
@@ -225,6 +243,7 @@
 						var command:String = String(tranArray[0]);
 						var args:String = String(tranArray[1]);
 						args = args.replace(')','');
+						args = args.replace(/,\s*/g, ','); 
 						var argsArray:Array = args.split(/[, ]/);
 						
 						switch (command) {
@@ -247,7 +266,6 @@
 								break;
 								
 							case "translate":
-															
 								if (argsArray.length == 1) {
 									this.x = SVGColors.cleanNumber(argsArray[0]) + SVGColors.cleanNumber(this.getAttribute('x'));									
 								}
@@ -496,9 +514,9 @@
 		 **/
 		protected function onNodeAdded(event:Event):void {
 			if (this.svgRoot) {	
-				var id:String = this._xml.@id;
-				if (id != "") {
-					this.svgRoot.registerElement(id, this);
+				this._id = this._xml.@id;
+				if (this._id != "") {
+					this.svgRoot.registerElement(this._id, this);
 				}
 			
 				this.svgRoot.dispatchEvent(new SVGMutationEvent(this, SVGMutationEvent.DOM_NODE_INSERTED)); 
@@ -664,6 +682,19 @@
 			return defaultValue;
 			
 		}
+
+		public function setAttribute(attribute:String, attrValue:*):void {
+			var xmlList:XMLList = this._xml.attribute(attribute);
+			xmlList[0] = attrValue;
+	
+			this.invalidateDisplay();
+		}
+
+		public function appendDomChild(xml:XML, parentId:String):void {
+			this.clearChildren();
+			this._xml.appendChild(xml);
+			this.invalidateDisplay();
+		}
 		
 		/**
 		 * Remove all child nodes
@@ -721,8 +752,21 @@
 				
 				if (!(this is SVGRoot)) {
 					this.svgRoot.invalidNodeCount--;
-				}
-									
+				} else {
+					// still fire that we are loaded if we are the
+					// SVG root but have no SVG child nodes
+					var hasNodes = false;
+					for (var i = 0; i < this.svgRoot.numChildren; i++) {
+						if (this.svgRoot.getChildAt(0) as SVGNode) {
+							hasNodes = true;
+							break;
+						}
+					}
+
+					if (!hasNodes) {
+						this.svgRoot.dispatchEvent(new SVGEvent(SVGEvent.SVG_LOAD));
+					}
+				}					
 			}
 		}
 		
@@ -732,6 +776,7 @@
 		override public function addChild(child:DisplayObject):DisplayObject {
 			
 			if (child is SVGNode) {				
+				this.svgRoot.totalNodeCount++;
 				this.svgRoot.invalidNodeCount++;
 			}
 			
Index: com/zavoo/svg/nodes/SVGTextNode.as
===================================================================
--- com/zavoo/svg/nodes/SVGTextNode.as	(revision 47)
+++ com/zavoo/svg/nodes/SVGTextNode.as	(working copy)
@@ -1,39 +1,41 @@
-/*
-Copyright (c) 2008 James Hight
-
-Permission is hereby granted, free of charge, to any person
-obtaining a copy of this software and associated documentation
-files (the "Software"), to deal in the Software without
-restriction, including without limitation the rights to use,
-copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the
-Software is furnished to do so, subject to the following
-conditions:
-
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-*/
-
+/*
+Copyright (c) 2008 James Hight
+
+Permission is hereby granted, free of charge, to any person
+obtaining a copy of this software and associated documentation
+files (the "Software"), to deal in the Software without
+restriction, including without limitation the rights to use,
+copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the
+Software is furnished to do so, subject to the following
+conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+*/
+
 package com.zavoo.svg.nodes
 {
+	import com.zavoo.svg.SVGViewer;
 	import com.zavoo.svg.data.SVGColors;
+	import com.zavoo.svg.data.SVGUnits;
 	
 	import flash.display.Bitmap;
 	import flash.display.BitmapData;
-	import flash.system.Capabilities;
 	import flash.text.Font;
 	import flash.text.TextField;
 	import flash.text.TextFieldAutoSize;
 	import flash.text.TextFormat;
+	import flash.text.TextFormatAlign;
 	import flash.text.TextLineMetrics;
 	
 	/** SVG Text element node **/
@@ -94,90 +96,129 @@
 		override protected function setAttributes():void {
 			
 			super.setAttributes();
-			
-			var embeddedFonts:Array = Font.enumerateFonts();
 			
+			var embeddedFonts:Array = Font.enumerateFonts();
+			
 			if (this._textField != null) {
 				var fontFamily:String = this.getStyle('font-family');				
 				var fontSize:String = this.getStyle('font-size');
-				var fill:String = this.getStyle('fill');
+				var fontWeight:String = this.getStyle('font-weight');
+				var fill:String = this.getStyle('fill');
+				var textAnchor:String = this.getStyle('text-anchor');
+				
+				if (/^\s*$/.test(textAnchor)) {
+					textAnchor = null;
+				}
 												
 				var textFormat:TextFormat = this._textField.getTextFormat();
-				
-				if (embeddedFonts.length == 0) { //No embedded fonts, use system fonts
+				
+				if (embeddedFonts.length == 0) { //No embedded fonts, use system fonts
 					this._textField.embedFonts = false;
 					if (fontFamily != null) {
 						fontFamily = fontFamily.replace("'", '');
 						textFormat.font = fontFamily;						
-					}
-				}
-				else { //Use embedded fonts
-					this._textField.embedFonts = true;					
-					textFormat.font = Font(embeddedFonts[0]).fontName;
-				}
+					}
+				}
+				else { //Use embedded fonts
+					this._textField.embedFonts = true;					
+					textFormat.font = Font(embeddedFonts[0]).fontName;
+				}
 				
-				if (fontSize != null) {
-					//Handle floating point font size
-					var fontSizeNum:Number = SVGColors.cleanNumber(fontSize);
-					
-					//Scale font to current DPI					
-					fontSizeNum *= Capabilities.screenDPI / 72;
-					
+				if (fontSize != null) {
+					//Handle floating point font size
+					var fontSizeNum:Number = SVGUnits.cleanNumber(fontSize);
+					
+					//Font size can be in user units, pixels (px), or points (pt); if no
+					//measurement type given defaults to user units
+					if (SVGUnits.getType(fontSize) == SVGUnits.PT) {
+						fontSizeNum = SVGUnits.pointsToPixels(fontSizeNum);
+					}
+					
 					var fontScale:Number = Math.floor(fontSizeNum);
-					textFormat.size = fontScale;
-					
-					fontScale = fontSizeNum / fontScale;
-					
-					_textField.scaleX = fontScale;
-					_textField.scaleY = fontScale;
+					textFormat.size = fontScale;
 					
-				}
+					fontScale = fontSizeNum / fontScale;
+					
+					this._textField.scaleX = fontScale;
+					this._textField.scaleY = fontScale;
+					
+				}
 							
 				if (fill != null) {
 					textFormat.color = SVGColors.getColor(fill);
 				}
+				
+				// only bold/no bold supported for now (SVG has many levels of bold)
+				if (fontWeight == 'inherit') {
+					// TODO
+				} else if (fontWeight != null && fontWeight != 'normal') {
+					textFormat.bold = true;
+				}
 								
 				this._textField.text = this._text;
 				this._textField.setTextFormat(textFormat);
-				
-				if (this._textBitmap != null) {
-					if (this.contains(this._textBitmap)) {
-						this.removeChild(this._textBitmap);
-					}
-					this._textBitmap = null;
-				} 
-				
-				if (this.contains(this._textField)) {
-					this.removeChild(this._textField);
-				}
-				
-				var textLineMetrics:TextLineMetrics = this._textField.getLineMetrics(0);
-								
+				
+				var textLineMetrics:TextLineMetrics = this._textField.getLineMetrics(0);
+				
+				//Handle text-anchor attribute
+				switch (textAnchor) {
+					case null:
+					case 'start':
+						// 2 pixel gutter
+						this._textField.x = -2;
+						break;
+					case 'middle':
+						this._textField.x = textLineMetrics.x - 2 - 
+						                          Math.floor(textLineMetrics.width / 2);
+						break;
+					case 'end':
+						this._textField.x = textLineMetrics.x - 2 - textLineMetrics.width;
+						break;
+					case 'inherit':
+						// TODO
+						break;
+				}
+				
+				//SVG Text elements position y attribute as baseline of text, not the
+				//top
+				this._textField.y = 0 - textLineMetrics.ascent - 2;	
+				
+				if (this._textBitmap != null) {
+					if (this.contains(this._textBitmap)) {
+						this.removeChild(this._textBitmap);
+					}
+					this._textBitmap = null;
+				} 
+				
+				if (this.contains(this._textField)) {
+					this.removeChild(this._textField);
+				}
+								
 				if (embeddedFonts.length == 0) { //No embedded fonts, so we need to render the text to bitmap to support rotated text
 					var bitmapData:BitmapData = new BitmapData(this._textField.width, this._textField.height, true, 0x000000);
-					
-					//Double resolution of bitmap
-					//this._textField.scaleX = this._textField.scaleX * 2;
-					//this._textField.scaleY = this._textField.scaleY * 2;
 					
+					//Double resolution of bitmap
+					//this._textField.scaleX = this._textField.scaleX * 2;
+					//this._textField.scaleY = this._textField.scaleY * 2;
+					
 					bitmapData.draw(this._textField);			
 					
-					this._textBitmap = new Bitmap(bitmapData);
-					//this._textBitmap.scaleX = 0.5;
+					this._textBitmap = new Bitmap(bitmapData);
+					//this._textBitmap.scaleX = 0.5;
 					//this._textBitmap.scaleY = 0.5;
-					this._textBitmap.smoothing = true;		
+					this._textBitmap.smoothing = true;		
 								
-					this._textBitmap.x = -2; //account for 2px gutter
-					this._textBitmap.y =  -2; //account for 2px gutter
-					
-					this._textField = null;
-				}
-				else { //There is an embedded font so display TextField				
-					
-					this._textField.x = -2; //account for 2px gutter
-					this._textField.y = -textLineMetrics.ascent - 2; //account for 2px gutter
+					this._textBitmap.x = this._textField.x;
+					this._textBitmap.y = this._textField.y;
 					
+					this._textField = null;
 				}
+				else { //There is an embedded font so display TextField				
+					
+					this._textField.x = -2; //account for 2px gutter
+					this._textField.y = -textLineMetrics.ascent - 2; //account for 2px gutter
+					
+				}
 			}
 		}	
 		
@@ -188,14 +229,14 @@
 			super.draw();
 			if (this._textBitmap != null) {
 				this.addChild(this._textBitmap);			
-			}		
-			if (this._textField != null) {
-				this.addChild(this._textField);			
+			}		
+			if (this._textField != null) {
+				this.addChild(this._textField);			
 			}	
-		} 		
-		
-		override protected function transformNode():void {
+		} 		
+		
+		override protected function transformNode():void {
 			super.transformNode();	
 		}	
 	}
-}
+}
Index: com/zavoo/svg/nodes/SVGTspanNode.as
===================================================================
--- com/zavoo/svg/nodes/SVGTspanNode.as	(revision 47)
+++ com/zavoo/svg/nodes/SVGTspanNode.as	(working copy)
@@ -23,15 +23,14 @@
 OTHER DEALINGS IN THE SOFTWARE.
 */
 
-package com.zavoo.svg.nodes
-{
-	import mx.collections.ArrayCollection;
-	
-	public class SVGTspanNode extends SVGTextNode
-	{		
-		public function SVGTspanNode(xml:XML):void {
-			super(xml);
-		}	
-		
-	}
+package com.zavoo.svg.nodes
+{
+	
+	public class SVGTspanNode extends SVGTextNode
+	{		
+		public function SVGTspanNode(xml:XML):void {
+			super(xml);
+		}	
+		
+	}
 }
