Our Episodic Video Player is written in ActionScript 3. I’m still fairly new to ActionScript but came up with a solution to a problem the other day that I thought I should share.
The player loads various files from the server. In some cases I want to display an error when one of those files can’t be found. I have an error handler that listens for Error Events and displays an appropriate error message depending on the type of the error event. For example, I know that error code 2032 will generally mean in our case that the file could not be found.
Alright, so this all seems simple enough except for one problem. When I looked at the ASDocs for ErrorEvent.errorID I noticed that that property is not available for Flash Player 9. Fortunately, ErrorEvent extends TextEvent which has text property I can access. In the case of an ErrorEvent the text property contains a message that includes the error ID. Therefore, I just wrote my own getter to grab the error ID.
public function get errorID():int {
if ((text != null) && (text.indexOf("Error #") == 0)
&& (text.length > 7)) {
// The Error IDs always seem to be 4 digits
return parseInt(errorEvent.text.substr(7, errorEvent.text.length - 7));
}