View Single Post
07-02-2008, 02:50 AM
#1
Petertang is offline Petertang
Petertang's Avatar
Status: Junior Member
Join date: Sep 2007
Location: Singapore
Expertise:
Software:
 
Posts: 51
iTrader: 0 / 0%
 

Petertang is on a distinguished road

Send a message via Yahoo to Petertang

  Old  Problem for Tracing the array value

Hi,

I have some problem to trace the array value in my actionscript. I am using the loadXML to load the datas from the XML file to my Flash movie and then assigned the value to the array i defined. But I have problem to trace my image data from the array i defined. Is anyone able to find out the problem I made over here? Below is my XML file and the actionscript I wrote.

Thanks

Here my Scripting in the Flash movie:
------------------------------------------------------------------------
var servicestypenos:Number = 1;
var dxmlfileaddr:String = 'xmlfile.xml';

var totalthisserdata:Number = 0;
var totalimgdata:Number = 6; //Set Max Number of Images per client data
var datasetnos:Number = 0;

myXMLdata = new XML();
myXMLdata.ignoreWhite = true;
myXMLdata.onLoad = loadXML;
myXMLdata.load(dxmlfileaddr);

function loadXML(loaded){
if (loaded) {
allGalleryData = this.firstChild;
clientname = [];
imgname = [];
desc = [];

//Define Total Sets of Data in the XML File
totaldata = allGalleryData.childNodes.length;
for(var i=0; i<totaldata; i++){
thissertype = allGalleryData.childNodes[i].childNodes[1].firstChild.nodeValue;
if(thissertype == servicestypenos){
// Check Total Number of Client data belong to this service type
totalthisserdata = totalthisserdata+1;
datasetnos = totalthisserdata-1;
clientname[datasetnos] = allGalleryData.childNodes[i].childNodes[2].firstChild.nodeValue;
desc[datasetnos] = allGalleryData.childNodes[i].childNodes[3].firstChild.nodeValue;

// Get Image name per clients data
for(var img=0; img<totalimgdata; img++){
imgname[[datasetnos][img]] = allGalleryData.childNodes[i].childNodes[4].childNodes[img].firstChild.nodeValue;
trace(datasetnos+","+img+":"+imgname[datasetnos][img]); //Problem

};
};
};
trace(imgname); //Problem of tracing all the img data


} else {
trace('file not loaded');
};
}
Here my set of data in the XMLfile: xmlfile.xml:
------------------------------------------------------------------------
<?xml version="1.0" encoding="ISO-8859-1" ?>
<PORTFOLIO>
<CLIENTS>
<CLIENTS_SN>1</CLIENTS_SN>
<SERVICES_TYPE>1</SERVICES_TYPE>
<NAME>port1</NAME>
<DESC>port1 description</DESC>
<IMG>
<PICT_1>eats1_1.jpg</PICT_1>
<PICT_2>eats1_2.jpg</PICT_2>
<PICT_3></PICT_3>
<PICT_4></PICT_4>
<PICT_5></PICT_5>
<PICT_6></PICT_6>
</IMG>
</CLIENTS>
<CLIENTS>
<CLIENTS_SN>2</CLIENTS_SN>
<SERVICES_TYPE>2</SERVICES_TYPE>
<NAME>port2</NAME>
<DESC>port2 description</DESC>
<IMG>
<PICT_1>eats2_1.jpg</PICT_1>
<PICT_2>eats2_2.jpg</PICT_2>
<PICT_3></PICT_3>
<PICT_4></PICT_4>
<PICT_5></PICT_5>
<PICT_6></PICT_6>
</IMG>
</CLIENTS>
<CLIENTS>
<CLIENTS_SN>3</CLIENTS_SN>
<SERVICES_TYPE>1</SERVICES_TYPE>
<NAME>port3</NAME>
<DESC>port3 description</DESC>
<IMG>
<PICT_1>eats3_1.jpg</PICT_1>
<PICT_2>eats3_2.jpg</PICT_2>
<PICT_3></PICT_3>
<PICT_4></PICT_4>
<PICT_5></PICT_5>
<PICT_6></PICT_6>
</IMG>
</CLIENTS>
</PORTFOLIO>
--------------------------------------------------------------------