Hi all,

I was trying to retrieve binary data over HTTP for my Flex application, and
was running into some stumbling blocks. HTTPService did not seem to deal
with binary data well, people said to use URLLoader. But URLLoader does not
have the nice AsyncToken/IResponder interface that HTTPService provides.

So, I did some searching and could not find anyone extending URLLoader to
provide this kind of functionality. I went ahead and took a stab at it
myself:  <http://pastebin.com/d7369d0e0> http://pastebin.com/d7369d0e0

Basically it wraps a URLLoader and an AsyncToken, and maps the COMPLETE,
IO_ERROR, and SECURITY_ERROR events from URLLoader to results/faults that
get raised on the AsyncToken.

Basic usage:

var tidbitLoader:AsyncURLLoader = new AsyncURLLoader();


tidbitLoader.dataFormat = URLLoaderDataFormat.BINARY;





var asyncToken:AsyncToken = tidbitLoader.load(new
URLRequest("http://localhost/SampleTidbit.swf";));





asyncToken.addResponder(this);





public function result(resultEvent:Object):void


{


    trace("result");


}





public function fault(faultEvent:Object):void 


{


    var fault:FaultEvent = faultEvent as FaultEvent;


    trace("fault: " + fault.toString());


}







Is this the right way to approach the problem? Are there existing solutions?
I would love to hear feedback.

Thanks,

Karthik

 

Karthik Kailash | Product

SocialVision, Online Television Becomes a Social Experience

CELL . 408.768.7704  | WEB . www.socialvisioninc.com | FACEBOOK .
<http://www.facebook.com/socialvision> facebook.com/socialvision | TWITTER .
<http://twitter.com/socialvision> twitter.com/socialvision

Reply via email to