So, let's say we want to load some XML -
var xmlURL:String = 'content.xml';
var xmlURLRequest:URLRequest = new URLRequest(xmlURL);
var xmlURLLoader:URLLoader = new URLLoader(xmlURLRequest);
xmlURLLoader.addEventListener(Event.COMPLETE, function(e:Event):void{
trace('loaded',xmlURL);
trace(XML(e.target.data));
});
If we need to know the source URL for this particular XML document, we have this variable to tell us, right? Now imagine that the xmlURL variable does not help us - perhaps we want to load 3 XML documents named sequentially and we want to use throwaway variables inside the for loop:
for(var i:uint = 3; i > 0; i--){
var xmlURLLoader:URLLoader = new URLLoader(new URLRequest('content'+i+'.xml'));
xmlURLLoader.addEventListener(Event.COMPLETE, function(e:Event):void{
trace(e.target.src);
trace(XML(e.target.data));
});
}
Suddenly it's not that simple, right?
I hate that you cannot just say e.target.src or something else - is there a good way to associate URLLoaders with the URL from which they downloaded the data? Am I missing something? It seems unintuitive to me.