Skip to main content
Participant
April 27, 2006
Question

Need help with setting a variable using actionscript

  • April 27, 2006
  • 1 reply
  • 189 views
So I am trying to import in XML and this is working fine, But once in flash I need to reference this variable in a later script. Here is what I got.


function loadXML(loaded) {
if (loaded) {

/////this is the variable, which is working, it pulls the info from the xml document properly.
var node1 = this.firstChild.childNodes[0].childNodes[0].firstChild.nodeValue;

////another variable, etc...
var node2 = this.firstChild.childNodes[0].childNodes[1].firstChild.nodeValue;


/////when traced it outputs the proper value.
trace(node1);

}}


////////does not work here though.

xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("co.xml");


var latmin = 37;
var latmax = 41;
var lonmin = -109;
var lonmax = -102;
this.geoPlotter_gp.setRange(latmin, latmax, lonmin, lonmax);
this.geoPlotter_gp.setNodeSymbol("geoPloterNodeSymbol");
this.geoPlotter_gp.addNode(40.48, -107);


////////////////This is where I need to now use the variables defined above//////////////



this.geoPlotter_gp.addNode(node1);// Boulder
this.geoPlotter_gp.addNode(node2);// Denver



/////any ideas all? I am sure this is something simple...I am just overlooking something.
This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
April 27, 2006
when you prefix a variable using var within a function, you're making it local to that function. ie, node1 and node2 are undefined outside loadXML().

to remedy, don't prefix with var.