Index: FD4/External/Plugins/ProjectManager/Projects/Haxe/HaxeOptions.cs
===================================================================
--- FD4/External/Plugins/ProjectManager/Projects/Haxe/HaxeOptions.cs	(revision 1945)
+++ FD4/External/Plugins/ProjectManager/Projects/Haxe/HaxeOptions.cs	(working copy)
@@ -13,6 +13,8 @@
         string mainClass = "";
         bool flashStrict = false;
         bool enableDebug = false;
+        bool useSamHaxe = false;
+        bool enableHeaderOutput = true;
         string[] additional = new string[] { };
         string[] libraries = new string[] { };
 
@@ -29,6 +31,18 @@
         public bool EnableDebug { get { return enableDebug; } set { enableDebug = value; } }
 
         [LocalizedCategory("ProjectManager.Category.CompilerOptions")]
+        [DisplayName("Use SamHaxe LibBuilder")]
+        [LocalizedDescription("ProjectManager.Description.UseSamHaxe")]
+        [DefaultValue(false)]
+        public bool UseSamHaxe { get { return useSamHaxe; } set { useSamHaxe = value; } }
+
+        [LocalizedCategory("ProjectManager.Category.CompilerOptions")]
+        [DisplayName("Enable Header Output")]
+        [LocalizedDescription("ProjectManager.Description.EnableHeaderOutput")]
+        [DefaultValue(true)]
+        public bool EnableHeaderOutput { get { return enableHeaderOutput; } set { enableHeaderOutput = value; } }
+
+        [LocalizedCategory("ProjectManager.Category.CompilerOptions")]
         [DisplayName("Flash Strict")]
         [LocalizedDescription("ProjectManager.Description.FlashStrict")]
         [DefaultValue(false)]
Index: FD4/External/Plugins/ProjectManager/Projects/Haxe/HaxeProject.cs
===================================================================
--- FD4/External/Plugins/ProjectManager/Projects/Haxe/HaxeProject.cs	(revision 1945)
+++ FD4/External/Plugins/ProjectManager/Projects/Haxe/HaxeProject.cs	(working copy)
@@ -134,9 +134,9 @@
 
                 if( htmlColor.Length > 0 )
                     htmlColor = ":" + htmlColor;
+                if( enableHeaderOutput )
+                    pr.Add("-swf-header " + string.Format("{0}:{1}:{2}{3}", MovieOptions.Width, MovieOptions.Height, MovieOptions.Fps, htmlColor));
 
-                pr.Add("-swf-header " + string.Format("{0}:{1}:{2}{3}", MovieOptions.Width, MovieOptions.Height, MovieOptions.Fps, htmlColor));
-
                 if( !UsesInjection && LibraryAssets.Count > 0 )
                     pr.Add("-swf-lib " + Quote(LibrarySWFPath));
 
@@ -195,7 +195,9 @@
             foreach (string opt in CompilerOptions.Additional) {
                 String p = opt.Trim();                   
                 if( p == "" || p[0] == '#' )
-                    continue;    
+                    continue;
+                //if (p == "-use-samhaxe" || p == "-no-swf-header")
+                //    continue;
                 char[] space = {' '};
                 string[] parts = p.Split(space, 2);
                 if (parts.Length == 1)
@@ -206,7 +208,22 @@
 
             return pr.ToArray();
         }
+        private bool enableHeaderOutput
+        {
+            get{
+                return CompilerOptions.EnableHeaderOutput;
+                /*
+                foreach (string opt in CompilerOptions.Additional) {
+                    String p = opt.Trim();                   
+                    if (p == "-no-swf-header")
+                        return true;
+                }
+                return false;
+                */
+            }
+        }
 
+
         #region Load/Save
 
         public static HaxeProject Load(string path)
Index: FD4/External/Plugins/ProjectManager/Projects/Haxe/HaxeProjectReader.cs
===================================================================
--- FD4/External/Plugins/ProjectManager/Projects/Haxe/HaxeProjectReader.cs	(revision 1945)
+++ FD4/External/Plugins/ProjectManager/Projects/Haxe/HaxeProjectReader.cs	(working copy)
@@ -98,6 +98,10 @@
                     case "flashStrict": options.FlashStrict = BoolValue; break;
                     case "mainClass": options.MainClass = Value; break;
                     case "enabledebug": options.EnableDebug = BoolValue; break;
+
+                    case "useSamHaxe": options.UseSamHaxe = BoolValue; break;
+                    case "enableHeaderOutput": options.EnableHeaderOutput = BoolValue; break;
+                        
                     case "additional": options.Additional = Value.Split('\n'); break;
                 }
                 Read();
Index: FD4/External/Plugins/ProjectManager/Projects/Haxe/HaxeProjectWriter.cs
===================================================================
--- FD4/External/Plugins/ProjectManager/Projects/Haxe/HaxeProjectWriter.cs	(revision 1945)
+++ FD4/External/Plugins/ProjectManager/Projects/Haxe/HaxeProjectWriter.cs	(working copy)
@@ -95,6 +95,10 @@
             WriteOption("flashStrict", options.FlashStrict);
             WriteOption("mainClass", options.MainClass);
             WriteOption("enabledebug", options.EnableDebug);
+
+            WriteOption("useSamHaxe", options.UseSamHaxe);
+            WriteOption("enableHeaderOutput", options.EnableHeaderOutput);
+
             WriteOption("additional", string.Join("\n", options.Additional));
             
             WriteEndElement();
Index: FD4/External/Tools/FDBuild/Building/Haxe/HaxeProjectBuilder.cs
===================================================================
--- FD4/External/Tools/FDBuild/Building/Haxe/HaxeProjectBuilder.cs	(revision 1945)
+++ FD4/External/Tools/FDBuild/Building/Haxe/HaxeProjectBuilder.cs	(working copy)
@@ -35,8 +35,18 @@
 
             if (project.IsFlashOutput)
             {
-                SwfmillLibraryBuilder libraryBuilder = new SwfmillLibraryBuilder();
+                LibraryBuilder libraryBuilder;
 
+                if (!useSamHaxe)
+                {
+                    libraryBuilder = new SwfmillLibraryBuilder();
+                    Console.WriteLine("using swfmill " + libraryBuilder);
+                }
+                else
+                {
+                    libraryBuilder = new SamHaxeLibraryBuilder();
+                    Console.WriteLine("using SamHaxe" + libraryBuilder);
+                }
                 // before doing anything else, make sure any resources marked as "keep updated"
                 // are properly kept up to date if possible
                 libraryBuilder.KeepUpdated(project);
@@ -56,5 +66,24 @@
             if (!ProcessRunner.Run(haxePath, haxeArgs, false))
                 throw new BuildException("Build halted with errors (haxe.exe).");
         }
+
+        private HaxeOptions Options { get { return (HaxeOptions)project.CompilerOptions; } }
+        private bool useSamHaxe
+        {
+            get
+            {
+                return Options.UseSamHaxe;
+                /*
+                foreach (string opt in Options.Additional)
+                {
+                    String p = opt.Trim();
+                    if (p == "-use-samhaxe")
+                        return true;
+                }
+                return false;
+                */
+            }
+        }
+
     }
 }
Index: FD4/External/Tools/FDBuild/Building/LibraryBuilder.cs
===================================================================
--- FD4/External/Tools/FDBuild/Building/LibraryBuilder.cs	(revision 0)
+++ FD4/External/Tools/FDBuild/Building/LibraryBuilder.cs	(revision 0)
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using ProjectManager.Projects;
+using ProjectManager.Building;
+using System.IO;
+
+namespace FDBuild.Building
+{
+    abstract class LibraryBuilder
+    {
+        public abstract void KeepUpdated(Project project);
+
+        public abstract void BuildLibrarySwf(Project project, bool verbose);
+    }
+}
Index: FD4/External/Tools/FDBuild/Building/SamHaxeLibraryBuilder.cs
===================================================================
--- FD4/External/Tools/FDBuild/Building/SamHaxeLibraryBuilder.cs	(revision 0)
+++ FD4/External/Tools/FDBuild/Building/SamHaxeLibraryBuilder.cs	(revision 0)
@@ -0,0 +1,115 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using ProjectManager.Projects;
+using ProjectManager.Building;
+using System.IO;
+
+namespace FDBuild.Building
+{
+    class SamHaxeLibraryBuilder : LibraryBuilder
+    {
+        static public string ExecutablePath;
+
+        public int Frame;
+
+        public override void KeepUpdated(Project project)
+        {
+            foreach (LibraryAsset asset in project.LibraryAssets)
+                if (asset.UpdatePath != null)
+                {
+                    string assetName = Path.GetFileName(asset.Path);
+                    string assetPath = project.GetAbsolutePath(asset.Path);
+                    string updatePath = project.GetAbsolutePath(asset.UpdatePath);
+                    if (File.Exists(updatePath))
+                    {
+                        // check size/modified
+                        FileInfo source = new FileInfo(updatePath);
+                        FileInfo dest = new FileInfo(assetPath);
+
+                        if (source.LastWriteTime != dest.LastWriteTime ||
+                            source.Length != dest.Length)
+                        {
+                            Console.WriteLine("Updating asset '" + assetName + "'");
+                            File.Copy(updatePath, assetPath, true);
+                        }
+                    }
+                    else
+                    {
+                        Console.Error.WriteLine("Warning: asset '" + assetName + "' could "
+                            + " not be updated, as the source file could does not exist.");
+                    }
+                }
+        }
+
+        public override void BuildLibrarySwf(Project project, bool verbose)
+        {
+            // compile into frame 1 unless you're using shared libraries or preloaders
+            Frame = 1;
+
+            string swfPath = project.LibrarySWFPath;
+
+            // delete existing output file if it exists
+            if (File.Exists(swfPath))
+                File.Delete(swfPath);
+
+            // if we have any resources, build our library file and run swfmill on it
+            if (!project.UsesInjection && project.LibraryAssets.Count > 0)
+            {
+                // ensure obj directory exists
+                if (!Directory.Exists("obj"))
+                    Directory.CreateDirectory("obj");
+                /*
+                string projectName = project.Name.Replace(" ", "");
+                string backupLibraryPath = Path.Combine("obj", projectName + "Library.old");
+                string relLibraryPath = Path.Combine("obj", projectName + "Library.xml");
+                string backupSwfPath = Path.Combine("obj", projectName + "Resources.old");
+                string arguments = string.Format("simple \"{0}\" \"{1}\"",
+                    relLibraryPath, swfPath);
+                */
+                string projectName = project.Name.Replace(" ", "");
+                string backupLibraryPath = Path.Combine("obj", projectName + "Library.old");
+                string relLibraryPath = Path.Combine("obj", projectName + "Library.xml");
+                string backupSwfPath = Path.Combine("obj", projectName + "Resources.old");
+                string arguments = string.Format("{0} {1}",
+                    relLibraryPath, swfPath);
+
+
+                SamHaxeLibraryWriter samHaxe = new SamHaxeLibraryWriter(relLibraryPath);
+                samHaxe.WriteProject(project);
+
+                if (samHaxe.NeedsMoreFrames) Frame = 3;
+
+                // compare the Library.xml with the one we generated last time.
+                // if they're identical, and we have a Resources.swf, then we can
+                // just assume that Resources.swf is up to date.
+                if (File.Exists(backupSwfPath) && File.Exists(backupLibraryPath) &&
+                    FileComparer.IsEqual(relLibraryPath, backupLibraryPath))
+                {
+                    // just copy the old one over!
+                    File.Copy(backupSwfPath, swfPath, true);
+                }
+                else
+                {
+                    // delete old resource SWF as it's not longer valid
+                    if (File.Exists(backupSwfPath))
+                        File.Delete(backupSwfPath);
+
+                    Console.WriteLine("Compiling resources");
+                    Console.WriteLine("SamHaXe " + arguments);
+
+                    if (verbose)
+                        //Console.WriteLine("swfmill " + arguments);
+                        Console.WriteLine("SamHaXe " + arguments);
+                    if (!ProcessRunner.Run(ExecutablePath, arguments, true))
+                        throw new BuildException("Build halted with errors (samHaxe).");
+
+                    // ok, we just generated a swf with all our resources ... save it for
+                    // reuse if no resources changed next time we compile
+                    File.Copy(swfPath, backupSwfPath, true);
+                    File.Copy(relLibraryPath, backupLibraryPath, true);
+                }
+            }
+        }
+    }
+}
Index: FD4/External/Tools/FDBuild/Building/SamHaxeLibraryWriter.cs
===================================================================
--- FD4/External/Tools/FDBuild/Building/SamHaxeLibraryWriter.cs	(revision 0)
+++ FD4/External/Tools/FDBuild/Building/SamHaxeLibraryWriter.cs	(revision 0)
@@ -0,0 +1,412 @@
+using System;
+using System.IO;
+using System.Text;
+using System.Xml;
+using ProjectManager.Projects;
+
+namespace ProjectManager.Building
+{
+    // builds a Library.xml file from a .fdp Project
+	public class SamHaxeLibraryWriter : XmlTextWriter
+	{
+        Project project;
+
+		public SamHaxeLibraryWriter(string libraryPath) : base(libraryPath, Encoding.UTF8)
+		{
+			base.Formatting = Formatting.Indented;
+		}
+
+		public void WriteProject(Project project)
+		{
+			this.project = project;
+
+			try { InternalWriteProject(); }
+			finally { Close(); }
+		}
+
+		// this function should be compacted at some point, it's got too many branches
+        /*
+        private void InternalWriteProject()
+		{
+			WriteStartDocument();
+			WriteComment("This file was generated by a tool (FDBuild).");
+			WriteComment("Any modifications you make may be lost.");
+			WriteStartElement("movie");
+
+            int maxFlashVersion = (project.Language == "haxe") ? 10 : 9;
+            int flashVersion = Math.Max(6, Math.Min(maxFlashVersion, project.MovieOptions.MajorVersion));
+            WriteAttributeString("version", flashVersion.ToString());
+
+			WriteAttributeString("width", project.MovieOptions.Width.ToString());
+			WriteAttributeString("height", project.MovieOptions.Height.ToString());
+			WriteAttributeString("framerate", project.MovieOptions.Fps.ToString());
+				WriteStartElement("background");
+				WriteAttributeString("color", project.MovieOptions.Background);
+				WriteEndElement();
+				WriteStartElement("frame");
+					WriteStartElement("library");
+                        WriteStartElement("clip");
+                            WriteAttributeString("id", GetSafeId("__sharepoint__"));
+                        WriteEndElement();
+						WritePreloaders();
+                        if (!NeedsMoreFrames)
+                            WriteNormalAssets();
+                        else
+                        {
+                            WriteStartElement("clip");
+                                WriteAttributeString("id", GetSafeId("__importtag__"));
+                            WriteEndElement();
+                        }
+					WriteEndElement();
+                    WriteSharedClips();
+				WriteEndElement();
+
+				if (NeedsMoreFrames)
+				{
+					WriteStartElement("frame");
+                    WriteSharedImports();
+					WriteEndElement();
+
+					// generate two extra frames (code will be injected into frame 3)
+					WriteStartElement("frame");
+						WriteElementString("stop","");
+						WriteStartElement("library");
+						WriteNormalAssets();
+						WriteEndElement();
+					WriteEndElement();
+                }
+			WriteEndElement();
+			WriteEndDocument();
+			Flush();
+		}
+        */
+        private void InternalWriteProject()
+        {
+            WriteStartDocument();
+            WriteComment("This file was generated by a tool (FDBuild).");
+            WriteComment("Any modifications you make may be lost.");
+            WriteStartElement("shx:resources");
+            
+            int maxFlashVersion = (project.Language == "haxe") ? 10 : 9;
+            int flashVersion = Math.Max(6, Math.Min(maxFlashVersion, project.MovieOptions.MajorVersion));
+            WriteAttributeString("version", flashVersion.ToString());
+            WriteAttributeString("compress", "false");
+
+            if (!((ProjectManager.Projects.Haxe.HaxeProject)project).CompilerOptions.EnableHeaderOutput)
+            {
+                WriteAttributeString("w", project.MovieOptions.Width.ToString());
+                WriteAttributeString("h", project.MovieOptions.Height.ToString());
+                WriteAttributeString("fps", project.MovieOptions.Fps.ToString());
+            }
+
+            WriteAttributeString("xmlns:shx", "http://mindless-labs.com/samhaxe");
+            WriteAttributeString("xmlns:img", "http://mindless-labs.com/samhaxe/modules/Image");
+            WriteAttributeString("xmlns:swf", "http://mindless-labs.com/samhaxe/modules/Swf");
+            WriteAttributeString("xmlns:snd", "http://mindless-labs.com/samhaxe/modules/Sound");
+            WriteAttributeString("xmlns:font", "http://mindless-labs.com/samhaxe/modules/Font");
+            WriteAttributeString("xmlns:bin", "http://mindless-labs.com/samhaxe/modules/Binary");
+            WriteAttributeString("xmlns:comp", "http://mindless-labs.com/samhaxe/modules/Compose");
+
+
+            //WriteStartElement("background");
+            //WriteAttributeString("color", project.MovieOptions.Background);
+            //WriteEndElement();
+
+
+            WriteStartElement("shx:frame");
+            //WriteStartElement("library");
+            //WriteStartElement("clip");
+            //WriteAttributeString("id", GetSafeId("__sharepoint__"));
+            //WriteEndElement();
+            WritePreloaders();
+            if (!NeedsMoreFrames)
+                WriteNormalAssets();
+            else
+            {
+                //WriteStartElement("clip");
+                //WriteAttributeString("id", GetSafeId("__importtag__"));
+                //WriteEndElement();
+            }
+            //WriteEndElement();
+            WriteSharedClips();
+            WriteEndElement();
+
+            if (NeedsMoreFrames)
+            {
+                WriteStartElement("shx:frame");
+                WriteSharedImports();
+                WriteEndElement();
+
+                // generate two extra frames (code will be injected into frame 3)
+                WriteStartElement("shx:frame");
+                //WriteElementString("stop", "");
+                //WriteStartElement("library");
+                WriteNormalAssets();
+                //WriteEndElement();
+                WriteEndElement();
+            }
+            WriteEndElement();
+            WriteEndDocument();
+            Flush();
+        }
+
+		#region Library Building
+
+		/*private void WritePlaceOnStage()
+		{
+			foreach (LibraryAsset asset in project.LibraryAssets)
+				if (asset.IsAS && asset.PlaceOnStage && File.Exists(asset.Path))
+				{
+					string id = asset.ID;
+
+					WriteStartElement("place");
+						WriteAttributeString("id",id);
+						WriteAttributeString("name","_"+id);
+						//WriteAttributeString("x","0");
+						//WriteAttributeString("y","0");
+					WriteEndElement();
+				}
+		}*/
+
+		private void WritePreloaders()
+		{
+			foreach (LibraryAsset asset in project.LibraryAssets)
+			{
+				// TODO: this is a crappy workaround for the general problem of
+				// project "cruft" accumulating.  This will be removed once
+				// I add support in the treeview for displaying "missing" project items
+	
+				if (!File.Exists(asset.Path))
+					continue;
+
+                if (asset.IsSwf && asset.SwfMode == SwfAssetMode.Preloader)
+                {
+                    WriteComment("PreloaderClip");
+                    AddAsset(asset);
+                }
+			}
+		}
+
+		private void WriteSharedClips()
+		{
+			//int depth = 0;
+
+			// place empty clips to the stage to signal to any preloaders what
+			// libraries need to be loaded
+			foreach (LibraryAsset asset in project.LibraryAssets)
+                if (asset.IsSwf && asset.SwfMode == SwfAssetMode.Shared)
+                {
+                    WriteComment("SharedClip");
+                    //AddAsset(asset);
+                    //WriteStartElement("place");
+                    //WriteAttributeString("id", GetSafeId("__importtag__"));
+                    //WriteAttributeString("name", "__library__" + asset.Path.Replace('\\', '/'));
+                    //WriteAttributeString("depth", (depth++).ToString());
+                    //WriteEndElement();
+                }
+		}
+
+		private void WriteSharedImports()
+		{
+			// import shared libraries
+			foreach (LibraryAsset asset in project.LibraryAssets)
+				if (asset.IsSwf && asset.SwfMode == SwfAssetMode.Shared)
+				{
+                    WriteComment("SharedImport");
+                    AddAsset(asset);
+					//WriteStartElement("import");
+					//WriteAttributeString("url", asset.Path);
+					//if (asset.Sharepoint != null)
+					//	WriteAttributeString("symbol", asset.Sharepoint);
+					//else
+					//	WriteAttributeString("file", asset.Path);
+					//WriteEndElement();
+				}
+		}
+
+		private void WriteNormalAssets()
+		{
+            WriteComment("NormalAssets");
+            foreach (LibraryAsset asset in project.LibraryAssets)
+			{
+				if (!File.Exists(asset.Path))
+					continue;
+	
+				if (!asset.IsSwf || asset.SwfMode == SwfAssetMode.Library)
+					AddAsset(asset);
+			}
+		}
+
+		// returns true if you have any shared libraries or preloaders
+		public bool NeedsMoreFrames
+		{
+			get
+			{
+				foreach (LibraryAsset asset in project.LibraryAssets)
+					if (File.Exists(asset.Path) && asset.IsSwf && 
+						asset.SwfMode != SwfAssetMode.Library)
+						return true;
+				return false;
+			}
+        }
+
+        private string GetSafeId(string id)
+        {
+            return (project.Language == "haxe") ? Char.ToUpper(id[2]) + id.Substring(3) : id;
+        }
+
+		#endregion
+
+		#region Adding Assets
+
+		private void AddAsset(LibraryAsset asset)
+		{
+            if (asset.IsImage) AddImage(asset);
+            else if (asset.IsFont) AddFont(asset);
+            else if (asset.IsSwf) AddSwf(asset);
+            else if (asset.IsSound) AddSound(asset);
+		}
+        /*
+		private void AddImage(LibraryAsset asset)
+		{
+            if (asset.BitmapLinkage)
+            {
+                WriteStartElement("bitmap");
+            }
+            else
+            {
+                WriteStartElement("clip");
+            }
+            WriteAttributeString("id", asset.ID);
+            WriteAttributeString("name", asset.ID);
+			WriteAttributeString("import", asset.Path);
+			AddStampAttributes(asset.Path);
+			WriteEndElement();
+        }
+        */
+        private void AddImage(LibraryAsset asset)
+        {
+            if (asset.BitmapLinkage)
+            {
+                WriteStartElement("img:image");
+            }
+            else
+            {
+                WriteStartElement("img:image");
+            }
+            WriteAttributeString("class", asset.ID);
+            WriteAttributeString("import", asset.Path);
+            WriteEndElement();
+        }
+        /*
+        private void AddSound(LibraryAsset asset)
+        {
+            //<sound id="Funk" name="Funk" import="Funk.mp3"/>
+            WriteStartElement("sound");
+            WriteAttributeString("id", asset.ID);
+            WriteAttributeString("name", asset.ID);
+            WriteAttributeString("import", asset.Path);
+            AddStampAttributes(asset.Path);
+            WriteEndElement();
+        }
+        */
+        private void AddSound(LibraryAsset asset)
+        {
+            WriteStartElement("snd:sound");
+            WriteAttributeString("class", asset.ID);
+            WriteAttributeString("import", asset.Path);
+            WriteEndElement();
+        }
+
+        /*
+		private void AddFont(LibraryAsset asset)
+		{
+			WriteStartElement("font");
+            WriteAttributeString("id", asset.ID);
+            WriteAttributeString("name", asset.ID);
+			WriteAttributeString("import", asset.Path);
+
+			if (asset.FontGlyphs != null)
+				WriteAttributeString("glyphs",asset.FontGlyphs);
+			else
+				WriteAttributeString("glyphs", "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ `~!@#$%^&*()-_=+[]{}\\|;:'\",./<>?");
+			
+			AddStampAttributes(asset.Path);
+			WriteEndElement();
+		}
+        */
+        private void AddFont(LibraryAsset asset)
+        {
+            WriteStartElement("font:ttf");
+            WriteAttributeString("class", asset.ID);
+            WriteAttributeString("name", asset.ID);
+            WriteAttributeString("import", asset.Path);
+
+            if (asset.FontGlyphs != null)
+            {
+                WriteStartElement("font:characters");
+                WriteStartElement("font:include");
+                WriteAttributeString("characters", asset.FontGlyphs);
+                WriteEndElement();
+                WriteEndElement();
+            }
+            else
+            {
+                WriteStartElement("font:characters");
+                WriteStartElement("font:include");
+                WriteAttributeString("characters", "1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ `~!@#$%^&*()-_=+[]{}\\|;:'\",./<>?");
+                WriteEndElement();
+                WriteEndElement();
+            }
+
+            WriteEndElement();
+        }
+
+        /*
+		private void AddSwf(LibraryAsset asset)
+		{
+			WriteStartElement("clip");
+
+            if (asset.SwfMode == SwfAssetMode.Library)
+            {
+                WriteAttributeString("id", asset.ID);
+                WriteAttributeString("name", asset.ID);
+            }
+			WriteAttributeString("import", asset.Path);
+			AddStampAttributes(asset.Path);
+			WriteEndElement();
+		}
+        */
+        private void AddSwf(LibraryAsset asset)
+        {
+
+            if (asset.SwfMode == SwfAssetMode.IncludedLibrary || asset.SwfMode == SwfAssetMode.ExternalLibrary)
+            {
+                WriteStartElement("swf:library");
+                WriteAttributeString("symbols", "true");
+
+            }
+            else
+            {
+                WriteStartElement("swf:swf");
+                WriteAttributeString("class", asset.ID);
+                //WriteAttributeString("genclass", "false");
+                //WriteAttributeString("genclass", "symbolOnly");
+                //WriteAttributeString("genclass", "symbolAndClass");
+            }
+            WriteAttributeString("import", asset.Path);
+            WriteEndElement();
+        }
+
+		private void AddStampAttributes(string path)
+		{
+			FileInfo file = new FileInfo(path);
+			WriteAttributeString("size", file.Length.ToString());
+			WriteAttributeString("modified", file.LastWriteTimeUtc.ToString());
+		}
+
+		#endregion
+	}
+
+
+}
Index: FD4/External/Tools/FDBuild/Building/SwfmillLibraryBuilder.cs
===================================================================
--- FD4/External/Tools/FDBuild/Building/SwfmillLibraryBuilder.cs	(revision 1945)
+++ FD4/External/Tools/FDBuild/Building/SwfmillLibraryBuilder.cs	(working copy)
@@ -7,13 +7,13 @@
 
 namespace FDBuild.Building
 {
-    class SwfmillLibraryBuilder
+    class SwfmillLibraryBuilder : LibraryBuilder
     {
         static public string ExecutablePath;
 
         public int Frame;
 
-        public void KeepUpdated(Project project)
+        public override void KeepUpdated(Project project)
         {
             foreach (LibraryAsset asset in project.LibraryAssets)
                 if (asset.UpdatePath != null)
@@ -42,7 +42,7 @@
                 }
         }
 
-        public void BuildLibrarySwf(Project project, bool verbose)
+        public override void BuildLibrarySwf(Project project, bool verbose)
         {
             // compile into frame 1 unless you're using shared libraries or preloaders
             Frame = 1;
Index: FD4/External/Tools/FDBuild/FDBuild.csproj
===================================================================
--- FD4/External/Tools/FDBuild/FDBuild.csproj	(revision 1945)
+++ FD4/External/Tools/FDBuild/FDBuild.csproj	(working copy)
@@ -2,7 +2,7 @@
   <PropertyGroup>
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
     <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProductVersion>9.0.21022</ProductVersion>
+    <ProductVersion>9.0.30729</ProductVersion>
     <SchemaVersion>2.0</SchemaVersion>
     <ProjectGuid>{FF680DE0-9CB7-45F4-BAFA-6EFFAAFD9C09}</ProjectGuid>
     <OutputType>Exe</OutputType>
@@ -152,6 +152,9 @@
     <Compile Include="Building\AS2\AS2ProjectBuilder.cs" />
     <Compile Include="Building\AS2\MtascArgumentBuilder.cs" />
     <Compile Include="Building\AS3\FlexConfigWriter.cs" />
+    <Compile Include="Building\LibraryBuilder.cs" />
+    <Compile Include="Building\SamHaxeLibraryBuilder.cs" />
+    <Compile Include="Building\SamHaxeLibraryWriter.cs" />
     <Compile Include="Building\SwfmillLibraryBuilder.cs" />
     <Compile Include="Building\SwfmillLibraryWriter.cs" />
     <Compile Include="Building\AS3\AS3ProjectBuilder.cs" />
Index: FD4/External/Tools/FDBuild/Program.cs
===================================================================
--- FD4/External/Tools/FDBuild/Program.cs	(revision 1945)
+++ FD4/External/Tools/FDBuild/Program.cs	(working copy)
@@ -48,6 +48,8 @@
             else
                 SwfmillLibraryBuilder.ExecutablePath = "swfmill.exe"; // hope you have it in your environment path!
 
+            SamHaxeLibraryBuilder.ExecutablePath = "SamHaXe.exe";
+
             try
             {
                 if (options.ProjectFile.Length > 0)
