RSS
email

Getting values from external XML file into flash:



Step1: Create new flash document

Step2: Right-click first frame and select actions

Step3: Paste the below code in first frame

var xm:XML = new XML();//creating XML object
xm.ignoreWhite = true;//white spaces will be discarded
xm.onLoad = function() {//function will be call when xml file data loaded into xml object
trace(this.firstChild)//indicates node and child nodes of it
trace("----------------------------------------------------------");
trace(this.firstChild.childNodes[0])//displays the child nodes of the first child alone(under node)
trace("----------------------------------------------------------");
trace(this.firstChild.childNodes[0].childNodes[0])//displays the child nodes of the alone
trace("----------------------------------------------------------");
trace(this.firstChild.childNodes[0].childNodes[0].firstChild)//displays the nodevalue of the alone

};
xm.load("sample.xml");//loading the xml file data into xml object

Step4: save the file as example.fla

Step5: Create xml file (may be notepad and change extension from .txt to .xml)

Step6: Paste the below data in XML

<?xml version="1.0"?>
<root>
<student><name>sara</name><age>23</age></student>
<student><name>manju</name><age>25</age></student>
<student><name>sind</name><age>23</age></student>
</root>

Step7: Save under the same path where flash file is (file name: sample.xml)

Note: name of the xml file and path is more important

Bookmark and Share

0 comments:

 

Recent Posts

Recent Visitors

Donate Me

About Me

My photo
Chennai, Tamil nadu, India
Nothing more to say about me.. Just a Action Script programmer / Flex developer having 4.5 years of experience.