Home > Flash development > IO Errors and Flash TileList

IO Errors and Flash TileList

October 24th, 2008 Leave a comment Go to comments

I am developing a custom video player for a client and I am using the Flash CS3 TileList component which loads thumbnails from a CDN. Sometimes the URL fails resulting in a runtime error and a dialogue thrown up by the Flash Player (if you have the debug version installed):

Error #2044: Unhandled ioError:. text=Error #2035: URL Not Found.

Only a tiny number of viewers will have the debug version installed and will not see this error, but those people count because they will be my colleagues and fellow flash developers and they will judge me harshly as a result. Oh yes. I really dislike it when other websites (like my blog ;) cause the Flash Player to throw up runtime errors, sometimes crashing my browser.

All you need to do add an event handler to catch the IO Event. But in this case it is not incredibly obvious where to add the event listener. Many thanks to Lanny McNie for pointing out how I can extend the TileList Class and add the event handler to the "activeCellRenderers".  Change the linkage to the TileList component in the library to point to your new class and you should be good to go.

Actionscript:
  1. package com.channelflip.video.control{
  2.    import fl.controls.TileList;
  3.    import flash.events.IOErrorEvent;
  4.  
  5.    public class VideoTileList extends TileList{
  6.       public function VideoTileList(){
  7.          super();
  8.       }
  9.       override protected function drawList():void{
  10.          super.drawList();
  11.          var length:Number = activeCellRenderers.length;
  12.          for (var index:Number=0; index
  13.             activeCellRenderers[index].addEventListener(IOErrorEvent.IO_ERROR, handleIOError, false, 0, true);
  14.          }
  15.       }
  16.       protected function handleIOError(p_evt:IOErrorEvent):void{
  17.          trace("caught IO Error: " + p_evt);
  18.  
  19.       }
  20.  
  21.    }
  22. }

Categories: Flash development Tags:
  1. No comments yet.
  1. No trackbacks yet.