My question really isn’t about how to load XML from a web service. Actually, the code below does that just fine. However, what I am having trouble with is accessing any of the XML data outside of the XMLLoaded function. Currently, if I want to use the XML data inside of other functions, I need to keep those functions nested withing the XMLLoaded function. For example, if I run the trace outside of the XMLLoaded function, a null value is returned. I’m sure that this is probably very simple but how would I get access to that data outside of it’s own function? It’s been a long week and I’m sure that my description of the problem is as confusing to you as the problem itself is confusing to me. Any help, however, would be greatly appreciated. Thank you.
import alducente.services.WebService;
import flash.events.*;
var ws:WebService = new WebService();
ws.addEventListener(Event.CONNECT, connected);
ws.connect(“http://10.1.138.22/FlashVideo/Service.asmx?WSDL”);
ws.cacheResults = true;
var initTime:Number;
var flashVideo:XMLList;
var soap:Namespace = new Namespace(“http://schemas.xmlsoap.org/soap/envelope/”);
var fv:Namespace = new Namespace(“http://tempuri.org/”);
default xml namespace = fv;
function connected(evt:Event):void {
ws.removeEventListener(Event.CONNECT, connected);
ws.GetFlashVideoData(XMLLoaded, 1);
}
function XMLLoaded(XMLData:XML):void {
flashVideo = XMLData.soap::Body.GetFlashVideoDataResponse.GetFlashVideoDataResult;
trace(flashVideo.MediaTitle);
}
import alducente.services.WebService;
import flash.events.*;
var ws:WebService = new WebService();
ws.addEventListener(Event.CONNECT, connected);
ws.connect("http://10.1.138.22/FlashVideo/Service.asmx?WSDL");
ws.cacheResults = true;
var initTime:Number;
var flashVideo:XMLList;
var soap:Namespace = new Namespace("http://schemas.xmlsoap.org/soap/envelope/");
var fv:Namespace = new Namespace("http://tempuri.org/");
default xml namespace = fv;
function connected(evt:Event):void {
ws.removeEventListener(Event.CONNECT, connected);
ws.GetFlashVideoData(XMLLoaded, 1);
}
function XMLLoaded(XMLData:XML):void {
flashVideo = XMLData.soap::Body.GetFlashVideoDataResponse.GetFlashVideoDataResult;
trace(flashVideo.MediaTitle);
}