These are the scripts you need to load an external XML file into Flash.

PART ONE – Basic Stuff

var xml:XML = new XML();
var xmlList:XMLList;
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest(“INSERT XML FILE HERE”));
xmlLoader.addEventListener(Event.COMPLETE, processXML);

The above script will load the XML file into memory.

xmlLoader.addEventListener(Event.COMPLETE, processXML);

function processXML(event:Event):void{
xml = XML(event.target.data);
xmlList = xml.children();

Flash XML Part 1

The Event Listener and the Function allows the dhildren of the RSS data to be loaded into an array format.

So now, you can use


to refer to each child starting at 0.

PART TWO – Loading Attribute/Tags from XML


This will load any tag from the XML line.

For example, if we had an XML file containing..

<image source=”images/pic1.png” thumb=”thumbnails/th1.png”>Rembrant at the Plaza.</image>

We would use this AS command to grab the source image file.


Flash XML Part 2

I hope this works out, its the most BASIC way to parse XML into AS3. If there are issues or questions, let me know.

4 comments so far

Add Your Comment
  1. Hi Adam, what are you loading the xml into? Most people load parse the xml into text area components… Thanks

    • The XML can be loaded into anything because it can turned into a variable.

  2. Thanks for this tutorial. Are you going to make a fresh Dreamweaver tutorial any time soon?

  3. This is my XML file……

    Name : Vikrant Aggarwal
    DOB : August 25 1982
    Sex : Male
    City : Dehradun


    This is my AS………

    function loadXMLData(loaded) {
    if (loaded) {

    _root.abc = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;
    abc_txt.text = _root.abc;

    _root.abcd = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;
    abcd_txt.text = _root.abcd;

    _root.abcde = this.firstChild.childNodes[0].childNodes[2].firstChild.nodeValue;
    abcde_txt.text = _root.abcde;

    _root.abcdef = this.firstChild.childNodes[0].childNodes[3].firstChild.nodeValue;
    abcdef_txt.text = _root.abcdef;

    var path:String = this.firstChild.childNodes[1].childNodes[0].firstChild.nodeValue, imageLoader;
    loadMovie(path, imageLoader);

    else {
    xmlFile = new XML();
    xmlFile.ignoreWhite = true;
    xmlFile.onLoad = loadXMLData;

    i want to load an1.jpeg but i think im doing wrong…..i put my xml,and fla and jpeg in same folder……..help me

    mail me at……..vickyaggarwalin2003@yahoo.co.in