Copy link to clipboard
Copied
This is probably a fairly simple question, but I've never seen any documentation on it so I'm not sure of the answer.
Let's say I have the following code:
var myLoader:URLLoader;
function someFunction(){
myLoader = new URLLoader();
myLoader.addEventListener(Event.COMPLETE, onComplete);
myLoader.load(new URLRequest("something"));
function onComplete(e:Event):void{
//Some Code.
}
}
function someOtherFunction(){
myLoader = new URLLoader();
myLoader.addEventListener(Event.COMPLETE, onComplete);
myLoader.load(new URLRequest("somethingElse"));
function onComplete(e:Event):void{
//Some Code.
}
}
My question is, would it be possible for these two URLLoaders to interfere with each other, for instance if they were executed at the same time--even though they're confined to different functions? Thanks for the help.
they're not going to get mixed up but the only thing that would load would be the last myLoader.load() that executes.
if you wanted both to load, you would need to use two different loaders.
Copy link to clipboard
Copied
that code is problematic. you only have one reference for two (or more) urlloaders.
if you only need one, use one:
var myLoader:URLLoader=new URLLoader();
function someFunction(){
myLoader.addEventListener(Event.COMPLETE, onComplete);
myLoader.load(new URLRequest("something"));
function onComplete(e:Event):void{
//Some Code.
}
}
function someOtherFunction(){
myLoader.addEventListener(Event.COMPLETE, onComplete);
myLoader.load(new URLRequest("somethingElse"));
function onComplete(e:Event):void{
//Some Code.
}
}
if you need more than 1, give them different references.
Copy link to clipboard
Copied
Kglad, thanks for the reply. in your example you're using a single URLLoader in different functions, so if those functions were executed at the same time would the eventListeners potentially get mixed up since you're adding 2 of them to the same URLLoader, or would they remain separate since they're confined to different functions? That's essentially what I was trying to find out with my original question.
Copy link to clipboard
Copied
they're not going to get mixed up but the only thing that would load would be the last myLoader.load() that executes.
if you wanted both to load, you would need to use two different loaders.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now