Hi all,
I have a ScrollPane component instance that I expect to throw an IOErrorEvent as it tries to load a file.?Essentially, I want to set it up to look for one file, and if it doesn't find it, it throws an errorEvent and then I handle that by looking for a different file.
I understand that the ScrollPane doesn't throw a standard IOError when this happens because the load is asynchronous, and that I need to listen for an IOErrorEvent.IO_ERROR event instead.?I've attached a listener for this on my ScrollPane, but it doesn't seem to ever catch the event.?Here's my code:
public class Pager extends MovieClip{
?
?var scroll_pane:ScrollPane;
?var fake_query_string:String;
?
?public function Pager(){
?trace('pager init.');
?fake_query_string = ''blah''; // THIS IS A BAD STRING TO TRY TO LOAD -- IT SHOULD FAIL
?
?scroll_pane = new ScrollPane(); // CREATE A SCROLLPANE INSTANCE
?addChild(scroll_pane); // PUT IT ON THE STAGE
?scroll_pane.addEventListener(IOErrorEvent.IO_ERROR, handle_io_error); // ADD LISTENER TO HANDLE IOERROREVENTS
?}
?
?private function handle_io_error(e:IOErrorEvent):void{
?trace('io error event caught.');
?}
?}
When I run this, I get the following message:
pager init.
Error #2044: Unhandled IOErrorEvent:. text=Error #2035: URL Not Found.
I would expect the listener on the scroll_pane object to handle this error, but it's not.?What am I missing??Any help is greatly appreciated.
unable to catch IOErrorEvent thrown by...Oh yeah, sorry, there is a line in that code to call the load method of the scrollPane also:
?public function Pager(){
?trace('pager init.');
?fake_query_string = ''blah'';
?
?scroll_pane = new ScrollPane();
?addChild(scroll_pane);
?scroll_pane.addEventListener(IOErrorEvent.IO_ERROR, handle_io_error);
?scroll_pane.load(fake_query_string);
?}
No comments:
Post a Comment