PDA

View Full Version : XML Problem



Fhavio
March 24th, 2010, 05:44 PM
Hi there i tried onw of the methods that i saw in a post in here, but the problem is to return that value..


var xmlLoader:URLLoader = new URLLoader();
xmlLoader.addEventListener(Event.COMPLETE, DATAXML);
xmlLoader.load(new URLRequest("galeria.xml"));

function DATAXML(e:Event):void {
var xmlData:XML=new XML(e.target.data);
}

function DATAXML2(id:Number):Function {
return function(e:Event) : void {
var xmlData:XML=new XML(e.target.data);
globais.vrb.nome = xmlData.pic[id].image[0];
trace (globais.vrb.nome); <-------- HERE THE OUTPUT IT'S OK
}
}

xmlLoader.addEventListener(Event.COMPLETE, DATAXML2(globais.vrb.num_i));

trace (globais.vrb.nome); <---- HERE THE OUTPUT IS UNDEFINED

"globais.vrb.[other]" <--- is my global object to make a global variable..

Say something i'm stuck..

Or give me another way to make this..:pac:

PS: Someone can give me some tutorial to understand much better the functions i'm confusing in using them, and passing event types, too many things.. i understand functions the problem is AS3 is very complex..

wvxvw
March 24th, 2010, 05:52 PM
Are you some sort of Microsoft lover? :D Why do you spell function names in all caps?
1. Don't use nested functions, ever.
2. Just open the URLLoader manual, it gives good example of how to do it right.
3. No, you cannot return value from an event handler.