Sign in to follow this  
batts

reading XML files in Flash

Recommended Posts

I am trying to embed a map into a flash file and want to pull the data from an XML file, not from a string (as is done in the examples that I downloaded - in "For Flash Developers - Overview"). I'm using the same data as the example, but saved it as an XML file.

 

 

 

When I try running this in Flash, the map loads, but it is not classified. The debugger tells me: "ERROR: No data to display. There isn't any node/element in the XML document. Please check if your dataURL is properly URL Encoded or, if XML has been correctly embedded in case of dataXML."

 

 

 

I was trying to read the XML file using this Actionscript:

 

 

 

var myXML:XML = new XML();

 

myXML.ignoreWhite = true;

 

myXML.load("worldTest.xml");

 

myXML.onLoad = function(success:Boolean){

 

if (success){

 

trace(myXML);

 

}

 

}

 

 

 

Any idea why this doesn't work, or why the XML file can't be read?

 

 

 

 

 

Thanks.

Share this post


Link to post
Share on other sites

Hi batts,

 
It seems that you are only loading the XML and not passing it to the chart object.
 
Please see below:
var myXML:XML = new XML();

myXML.ignoreWhite = true;

myXML.load("worldTest.xml");

myXML.onLoad = function(success:Boolean){

if(success){

myWorldMap1.setXMLData(myXML);

myWorldMap1.render(); 

 }else {

myWorldMap1.log ("XMLData1","Load Failed",1);

 }}

 Where myWorldMap1 is the map object.
 
Please try the above code once.

Share this post


Link to post
Share on other sites

This is what I was using to pass the data to my map - I just didn't copy/paste that part in the last message because I figured that the problem was with reading the XML file:

 

 

 

var myFirstMap:WorldMap = new WorldMap(mapContainerMC, 1, 450, 315, 20, 20, true, "EN", "noScale", false, "");

 

//Convey the XML data to map.

 

myFirstMap.setXMLData(myXML);

 

//Draw the map

 

myFirstMap.render();

Share this post


Link to post
Share on other sites

I figured it out - even though I was loading the xml data into the map, I was doing it in the wrong place in my actionscript.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this