views:

46

answers:

1

In Chrome upon network error, the event object in error handler is behaving differently than IE and flash player (i.e. directly running the swf, not from the browser). Consider the following test code :

private function loadData():void {
    var loader:URLLoader = new URLLoader();
    loader.addEventListener(IOErrorEvent.IO_ERROR, onError);
    loader.addEventListener(Event.COMPLETE, onColmplete);
    loader.load(new URLRequest("http://www.jsfbjdsssde.com"));
    debugField.text = "loading";    // this is a TextField
}

private function onColmplete(evt:Event):void {
    debugField.text = "complete";
}

private function onError(evt:IOErrorEvent):void {
    debugField.text = "error : " + evt.text;
}

In IE and flash player, debugField shows

error : Error #2032: Stream Error. URL: http://www.jsfbjdsssde.com
but in Chrome it is
error : Error #2032
That is URL is stripped from the text. Why this is different? Anyone can suggest any way to get the URL in error handler? Or is this a bug of Chrome itself?


My Chrome version is 5.0.375.86

+1  A: 

I have not checked this, but it's quite likely that you have the release version of the flash plugin installed in Chrome (instead of the debug version). Debugging output is less verbose in the release player.

Juan Pablo Califano
That might be the case. Manual from adobe have not said anything details whether the URL will be included or not (at least I have failed to find it). Is there any proper way to get the URL in error listener? Or we should never rely on it?
taskinoor
@taskinoor. The only reliable way I can think of is keeping track of it yourself. Relying on parsing an error message string seems brittle, at best: it's not really part of the API. It could basically change without notice (also, as it seems to be the case, it might not be available always).
Juan Pablo Califano
On the other hand, you do know for sure the url when you start the loader. It could be as simple as having an extra variable (if you don't make more than one call at the time). If you want to throw some more structure at it, you can make a custom loader that uses a URLLoader internally and exposes the requested url through a getter or even create a custom event that passes the url along with the response data (or maybe not only the url but the whole URLRequest object, if that makes sense for what you're trying to do).
Juan Pablo Califano
Thanks Juan for the suggestion. I think I need to modify the code.
taskinoor