  | |  | Creating variables from XML | Creating variables from XML
2004-02-19 - By Sanjeev J Singh
Back Hi,
I am trying to read an XML and create variables at _level0. Here 's my code
(in the first frame of the main timeline):
thisXML = new XML();
thisXML.ignoreWhite = true;
thisXML.onLoad = DoOnLoad;
thisXML.load( "navstate.xml ");
function DoOnLoad () {
level1Child = this.firstChild;
var varname1;
var varname2;
var varvalue;
for (i=0; i <level1Child.childNodes.length; i++) {
for (j=0; j <level1Child.childNodes[i].childNodes.length; j++) {
varname1 = level1Child.childNodes[i].nodeName.toLowerCase();
varname2 =
level1Child.childNodes[i].childNodes[j].nodeName.toLowerCase();
varvalue = level1Child.childNodes[i].childNodes[j].firstChild.nodeValue;
set( "_level0. "+ varname1 add varname2, varvalue);
}
}
}
This creates variables (as displayed in the debug variables window) such as:
_level0.menuvisible = "1 "
_level0.menuenabled = "1 "
_level0.menuurl = "javascript:ShowMenu() ";
...etc.
The problem: If I trace these variables from within the DoOnLoad() function
I get the values but I cannot access these variables outside this function
from other functions (which is what I want to do).
What should I do to be able to create global variables as described above?
I 'm talking Flash 5.
Thanks,
Sanjeev
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Supported by Fig Leaf Software
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
Be sure to check the archives and the wiki:
http://chattyfig.figleaf.com/
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
http://chattyfig.figleaf.com/cgi-bin/ezmlm-cgi?1:mss:104685
=-- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- --
To unsubscribe send a blank e-mail to:
Normal Mode: flashcoders-unsubscribe@(protected)
Digest Mode: flashcoders-digest-unsubscrive@(protected)
|
|
 |