TypeError on HttpError (IOErrorEvent)

6 views
Skip to first unread message

mr

unread,
Nov 10, 2008, 12:25:49 PM11/10/08
to AS3 HttpClient, ma...@ruggier.org
Hi!

I am looking at as3-httpclient for use instead of mx:HTTPService,
given that latter's lack of HTTP support... just encountered this
problem, that is maybe not coming from me misusing the lib. I get the
following TypeError when I send a request (a simple GET in my code)
for a URI behind which theer is no web applicatin listening (the app
is hut dow...):

TypeError: Error #1034: Type Coercion failed: cannot convert
flash.events::IOErrorEvent@9335ba1 to
org.httpclient.events.HttpErrorEvent.
at org.httpclient.events::HttpListener/onInternalError()[/Users/gabe/
Projects/as3httpclient/src/org/httpclient/events/HttpListener.as:79]
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at org.httpclient::HttpSocket/onIOError()[/Users/gabe/Projects/
as3httpclient/src/org/httpclient/HttpSocket.as:309]

The simple error handler I am passing on the listereners object is:

onError: function(event:HttpErrorEvent):void {
Alert.show(event.text, "HTTP Error");
trace(event);
trace("httpError", event.text);
},

Am I misunderstanding something? What should the handler's event type
be?

mario

schickm

unread,
Nov 10, 2008, 12:30:03 PM11/10/08
to AS3 HttpClient
all you should have to do is change the event type to match the one
that is being coerced. When ever you see a "Type Coercion failed"
error it means that one type is trying to be converted into another
type, is this case it is trying to convert an IOErrorEvent into a
HttpErrorEvent. So all you should have to do is change the 'event'
function parameter to be typed as IOErrorEvent:

onError: function(event:IOErrorEvent):void {
Alert.show(event.text, "HTTP Error");
trace(event);
trace("httpError", event.text);
},

gabe

unread,
Nov 10, 2008, 1:31:58 PM11/10/08
to AS3 HttpClient
Actually it should be:

onError: function(event:ErrorEvent):void {

Both IOErrorEvent and HttpErrorEvent are subclasses of ErrorEvent and
both can be passed to the onError listener. The example wiki page had
it wrong, but should be fixed now.

mr

unread,
Nov 10, 2008, 1:45:41 PM11/10/08
to AS3 HttpClient
Thanks... i switched the typedecl to the generic ErrorEvent.

But, this kind unjustifies having the HttpErrorEvent class in teh
first place, other than just to have it declare a couple of consts...

mario
Reply all
Reply to author
Forward
0 new messages