Import a simple string variable

Action Script 2.0 variable from xml file

Page 1 of 1

1 Replies - 5172 Views - Last Post: 05 August 2007 - 09:29 PM

#1 alantone  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 05-August 07

Import a simple string variable

Post icon  Posted 05 August 2007 - 08:07 PM

I'm using Flash CS3 and I need to modify an existing flash movie to get a variable fron an xml file called settings.xml and assign it to a variable called movieName. The existing movie uses Action Script 2.0.

It seems like it should be really simple (one line of code?), but I've tried about a dozen snippets of code and none seem to work.

Thanks in advance!!
Is This A Good Question/Topic? 0
  • +

Replies To: Import a simple string variable

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1642
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Import a simple string variable

Posted 05 August 2007 - 09:29 PM

This will load the first node's value into a variable. This is to give you an idea on how to read xml data in ActionScript

function loadXML(loaded) 
{
   if (loaded) 
   {
	  xml = this.firstChild;
	  movieName = "";
	  movieName = xml.childNodes[0].childNodes[0].firstChild.nodeValue;

   } else {
			 content = "file not loaded!";
		  }
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onload = loadXML;
xmlData.contentType = "text/xml";
xmlData.load("settings.xml");



If the value isn't in the first child node you will need to loop through the file until you get to the node you are looking for.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1