# Function sequence problem

**URL:** https://forum.kirupa.com/t/function-sequence-problem/167906
**Category:** Uncategorized
**Created:** [November 2, 2005, 9:33am UTC](https://forum.kirupa.com/t/function-sequence-problem/167906 "2005-11-02T09:33:59Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![superprg](https://avatars.discourse-cdn.com/v4/letter/s/858c86/32.png) [@superprg](https://forum.kirupa.com/u/superprg)
#### Post date: [November 2, 2005, 9:33am UTC](https://forum.kirupa.com/t/function-sequence-problem/167906/1 "2005-11-02T09:33:59Z")

</div>

Please see the actionscript

[AS]  
XMLDoc = new XML();  
//xmldocurl = \_root.dataurl;  
//If no path has been provided, then just load a default XML file. This part is optional.  
//if (xmldocurl.length\<1) {  
tinterval=" ";  
xmldocurl = “product.xml”;

\_global.productname=new Array();  
\_global.productvalue=new Array();  
//}  
//Load the XML document  
[//XMLDoc.load](https://XMLDoc.load)(xmldocurl+"?curr="+getTimer());  
trace(XMLDoc.load(xmldocurl));  
XMLDoc.onLoad = fnloaded;  
OnUpdate();

function fnloaded()  
{

num=0;  
cldnodes = new Array();

cldnodes = XMLDoc.childNodes;  
dataset=cldnodes[0].childNodes;  
//Time interval  
// tinterval=cldnodes[0].attributes.tinterval;  
// trace(“Time:”+cldnodes[0].attributes.tinterval);  
trace(dataset.length);  
for (k=0; k\<=dataset.length; k++)  
{  
if (dataset[k].nodeName == “set”)  
{  
//Increment counter  
num = num+1;  
//Get the x-axis name  
\_global.productname[num] = dataset[k].attributes.name;  
//Get the value  
\_global.productvalue[num] = dataset[k].attributes.value;  
// trace(\_global.productname[num]);  
trace(“Value:in fnloaded”+\_global.productvalue[num]);

}  
}  
//OnUpdate();

}

function OnUpdate()  
{  
// var fileContents = “productvals”;  
var fileContents = “\<productvals tinterval=”;  
// fileContents=fileContents+tinterval;  
trace(“Third:”+\_global.productname[3]);  
//“This is the string we are writing to the filejksdfsdj jksdf l.”;

/\*  
for(x=1;x\<=num/2;x++)  
{  
//fileContents=fileContents+"  
“+”\<set name="+productname[x]+" value=""+productvalue[x]+""/\>";  
fileContents=fileContents+""+"=";  
}  
\*/  
trace(fileContents);  
loadVarsText = new LoadVars();  
loadVarsText.onLoad = function(success) {  
if (success) {  
if (this.wroteFile)  
{  
trace(“Success! Write to file complete.”);  
}  
else  
{  
trace(“Error, write to file failed!.”);  
}  
}  
else  
{  
trace(“Error, loadVars failed!”);  
}  
}  
loadVarsText.load("\<A href=“[http://localhost/writeFile.php?&stuffToWrite="+fileContents"](http://localhost/writeFile.php?&stuffToWrite=%22+fileContents%22)\>[http://localhost/writeFile.php?&stuffToWrite=](http://localhost/writeFile.php?&stuffToWrite=)”+fileContents);

}  
[/AS]  
The calling sequence is  
XMLDoc.onLoad = fnloaded;  
OnUpdate();  
I dont know why I am getting in trace(“Third:”+\_global.productname[3]); as undefined!!  
Please help!  
Thanks
