PDA

View Full Version : Getting XML content inside a class



Balala
November 8th, 2005, 08:32 AM
Take a look at these example:


function loadMap():Void {
var xdata:XML = new XML();
xdata.ignoreWhite = true;
xdata.load(this.source_map);

var var_temp:String;

xdata.onLoad = function(success:Boolean) {
if(success) {
var_temp = xdata.firstChild;
} else {
trace("Cannot load xml file = " + this.source_map);
}
}
}

Now, im creating a local variable var var_temp:String; cause, there is no way that i can pass the values, inside the onLoad handler to a property of the class.

If i try some this.some_var its reference to escope inside the onLoad handler... :(

Any solution to get the values to a class property?

kernel_flash
November 8th, 2005, 08:37 AM
Just a little modification.
instead of
var_temp=xData.firstChild;
use

var_temp=this.firstChild

Balala
November 8th, 2005, 10:26 AM
Ok, but the true problem is to get the content of the XML to a class property, not just stay on function scope :(