Flash Tutorials
How to Create Randomly Flying Away Movie
How to Place Flat Subject in Space
How to Place Flat Subject in Space (Russian)
How to Use loadMovie Function
How to Skew the Object
How to Load XML File
How to load XML file...

You can load XML file in your program written on flash. Actually it can be any file that is in the same subdomain as the URL where the movie currently resides.
To make it create new FLA with text window and any Movie Clip on scene that we are going to use as something on what we can write on enterFrame event handler (let's call this Movie Clip timer). OK, our scene must look like:



Now we will write script only, no design at all!
On the timer object we have to create two events:

onClipEvent (load) {
_visible=0;
}
onClipEvent (enterFrame) {
_parent.fnOnEnterFrame();
}
On the first frame of your scene type:

var UrlXML='P2.xml';  //URL to XML file
var XmlR=new XML(); //XML object
//XmlR.ignoreWhite=true;  //Uncomment this line if you wand ignore spaces in XML
var ILoadXML=1; //Auxiliary variable
/*f***********/
function  fnOnEnterFrame()
{
//We enter here on every frame
if(ILoadXML!=null)
{
readXML();
if(ILoadXML==0)
{
txtRes.text=XmlR.toString();
ILoadXML=null;
}
}
}
/*f***********/
function  readXML()
{
if(ILoadXML==0.25)
ILoadXML=0;
if(ILoadXML==0.5)
{
if(XmlR.loaded)
ILoadXML=0.25;
}
if(ILoadXML==1)
{
XmlR.load(UrlXML);
ILoadXML=0.5;
}
}
    


Create file P2.xml in the same folder where your FLA is, containing the following information:

<data>
<tag1>Value1</tag1>
<tag2>
<tag2_1>Value2_1</tag2_1>
</tag2>
</data>
    


Run the movie and you should see:




How can we use it?..
Example. Changing text in the text field from XML file.
This movie is getting two phrases from XML file by turns.

ZIP is here: XMLLoadUse.zip (Macromedia Flash MX file + XML file).
Remarks
wayne derflinger
2010-09-16 13:28:12
http://yahh.com
hi im wayne derflinger an gog bless youall
re
2007-03-14 06:55:23
teste
cam
2004-08-11 00:12:27
catlam07@yahoo.com
http://www.geocities.com/ca
milallam
more xml to flash mx and <
Add Your Remark:
Your Name*:
Email:
Hide Email    Subscribe to Site News
Web Site:
Message*:
Other tutorials:
JavaScript Tutorials