Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,256
Total Threads: 81,169
Total Posts: 566,838
There are 41 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     Flash and Actionscript :

Problem for Tracing the array value

Thread title: Problem for Tracing the array value
Closed Thread    
    Thread tools Search this thread Display Modes  
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>
--------------------------------------------------------------------

07-05-2008, 03:48 PM
#2
Tom W is offline Tom W
Tom W's Avatar
Status: I'm new around here
Join date: Feb 2008
Location:
Expertise:
Software:
 
Posts: 24
iTrader: 0 / 0%
 

Tom W is on a distinguished road

  Old  Array Problem

You could try making your arrays associative arrays clientname = {}, imgname = {}, desc = {} instead. This way you can have values assigned to them with at datasetnos, img, etc., (clientname["datasetnos"]= ...) you can't do that with normal arrays (array = []). Normal arrays can only have values such as array = ["a", "b", "c"]

07-13-2008, 03:05 AM
#3
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

Thanks Tom for your replied.

But I got the problem solved by defining an array within an array by adding "imgname[datasetnos] = []" after "desc[datasetnos] = allGalleryData.childNodes[i].childNodes[3].firstChild.nodeValue;"

Closed Thread    


Thread Tools
Display Modes

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed