wagster
09-13-2009, 10:24 PM
So... I have a textfield with a number of embedded images, each with an id of "0", "1", "2" etc...
I have a short function that counts through all the images in the textfield, however many there may be, and adds an IOErrorEvent listener to each one.
The error handler then gets a reference to the LoaderInfo object which is associated with the Loader object that is failing to load an image. The LoaderInfo object has a "loader" property which provides a reference to the Loader object. I want to tell that Loader object to close() it's current load operation and then pass it a new URLRequest and load something else instead.
Problem is, when I call LoaderInfo.loader.close() I get:
Error #2099: The loading object is not sufficiently loaded to provide this information.
How do I access the Loader object and tell it to load something else?
Here's the code:
private function addImageListeners():void{
var i:int = 0;
while (displayBox.getImageReference(i.toString()) != null){
var l:Loader = displayBox.getImageReference(i.toString()) as Loader;
l.contentLoaderInfo.addEventListener(IOErrorEvent. IO_ERROR,IOErrorHandler;
i++;
}
}
private function IOErrorHandler (e:IOErrorEvent):void{
trace ("ERROR EVENT CAUGHT BY IOErrorHandler");
e.target.loader.close();
}
I have a short function that counts through all the images in the textfield, however many there may be, and adds an IOErrorEvent listener to each one.
The error handler then gets a reference to the LoaderInfo object which is associated with the Loader object that is failing to load an image. The LoaderInfo object has a "loader" property which provides a reference to the Loader object. I want to tell that Loader object to close() it's current load operation and then pass it a new URLRequest and load something else instead.
Problem is, when I call LoaderInfo.loader.close() I get:
Error #2099: The loading object is not sufficiently loaded to provide this information.
How do I access the Loader object and tell it to load something else?
Here's the code:
private function addImageListeners():void{
var i:int = 0;
while (displayBox.getImageReference(i.toString()) != null){
var l:Loader = displayBox.getImageReference(i.toString()) as Loader;
l.contentLoaderInfo.addEventListener(IOErrorEvent. IO_ERROR,IOErrorHandler;
i++;
}
}
private function IOErrorHandler (e:IOErrorEvent):void{
trace ("ERROR EVENT CAUGHT BY IOErrorHandler");
e.target.loader.close();
}