Flash addXMLPath example

I was recently working on an application in Flash which required the use of Flash’s Locale class. It didn’t take long before I was consulting the documentation for some of the methods and I ran across the addXMLPath method. Adobe (Macromedia at the time) was nice enough to include an example of how to use Locale.addXMLPath, however the example provided doesn’t even use addXMLPath()! The example provides no extra help whatsoever. I’ve created this small article to give an example on how to use Locale.addXMLPath().

Actually, using addXMLPath is pretty straight forward. It’s main purpose is to load XML language files from a custom location instead of the default set up by Flash. If you’ve ever created an XLIFF file using Flash’s Strings panel, then you should know that Flash creates an XML file for each language, but it puts it in your working directory, under a subdirectory and named using your FLA’s filename. Example:


If you have Flash file that needs to open an XLIFF file from another directory, you will need to use addXMLPath() to tell Flash where to find that file. Simply put, addXMLPath sets the path to XML files holding the translations for the specified language. An example:

Locale.addXMLPath("en", "../locale/locale_en.xml");

The above example tells the Locale class that English (“en”) translations are found in the file “../locale/locale_en.xml”. Note that you can specify a separate path for each language and this path can be relative to the working directory. This is handy when, like me, you are turned off by the fact that Flash makes a new directory for each language’s XML file. I personally would like to see all the languages in one directory. If I put all my language XML files in a folder called “locale” then this is how I would use addXMLPath:

Locale.addXMLPath("en", "locale/locale_en.xml");
Locale.addXMLPath("fr", "locale/locale_fr.xml");
Locale.addXMLPath("ko", "locale/locale_ko.xml");
Locale.setLoadCallback(Delegate.create(this, languageLoaded));

private function languageLoaded(success:Boolean):Void {

And there you have it… A (detailed) example of how to use addXMLPath.

3 Thoughts on “Flash addXMLPath example

  1. yurgelis on February 11, 2010 at 9:27 am said:

    hola esperon que me ayuden, estoy tratando de abrir un juego que se llama farm ville y me aparece una leyenda que dice que el archivo flashLocaleXml.xml_4.gz esta dañado, quisiera saber si eso es el juego o es mi pc? gracias, saludos y espero su respuesta

  2. and you couldn’t be a little forgiving, in the dictionary they said ‘thank you chris’ and here you’ve bashed them in the intro. you’re da man chris.

  3. socalfish on September 8, 2011 at 9:06 am said:

    Good article… BUT i recently discovered that having more then one xml file causes a problem with Locale. I use seperate fla files for various launching from a Main Menu. Am trying to sperate my language files. It’s fine when running stand alone, but when you addXMLPath and another file it only reads in the previous Locale loaded. Any suggestions how I can use multiple Locale XML files?

Leave a Reply

Post Navigation