lewispeel Posted March 27, 2013 Posted March 27, 2013 Hi, Is there a way to grab the response headers from the LoaderEvent? Thanks, Lewis
GreenSock Posted March 27, 2013 Posted March 27, 2013 Not consistently (that I know of), no - apparently some browsers limit access to that info, so Flash has a tough time with it. I believe that you can listen for HTTP_RESPONSE_STATUS events if you're publishing to AIR, and the resulting event will usually have a responseHeaders property (get to the original event using the LoaderEvent's "data" property, and make sure you're using the latest version of the LoaderMax files). Again, that's only for AIR apps. I wish I had better news for you.
lewispeel Posted March 27, 2013 Author Posted March 27, 2013 Ah ok, that's fine...I'm using AIR and have no intention of targeting a browser. I was hoping to make use of the 'onHTTPStatus' event handler shortcut in DataLoaderVars and grab them from the LoaderEvent. Thanks for the speedy reply Jack. Keep up the good work!!
lewispeel Posted March 27, 2013 Author Posted March 27, 2013 Hmm, I seem to be getting a null value for event.data. Here's a very basic example... package { import com.greensock.events.LoaderEvent; import com.greensock.loading.DataLoader; import com.greensock.loading.LoaderMax; import com.greensock.loading.data.DataLoaderVars; import flash.display.Sprite; import flash.net.URLRequest; public class Spike extends Sprite { private var requestQueue:LoaderMax; private var loaderVars:DataLoaderVars; public function Spike() { requestQueue = new LoaderMax({ name : "SpikeQueue", maxConnections : 20 }); loaderVars = new DataLoaderVars({ autoDispose : true, format : "text", onHTTPStatus : onHTTPStatusHandler, onComplete : onCompleteHandler, onFail : onFailHandler }); makeRequest(); } private function makeRequest():void { var request:URLRequest = new URLRequest( "http://search.twitter.com/search.json?q=greensock" ); var loader:DataLoader = new DataLoader( request, loaderVars ); requestQueue.append(loader); requestQueue.load(); } private function onHTTPStatusHandler( event : LoaderEvent ):void { var loader:DataLoader = DataLoader( event.currentTarget ); trace( "onHTTPStatusHandler" ); trace( "loader.httpStatus = " + loader.httpStatus ); trace( "event.data = " + event.data ); } private function onCompleteHandler( event : LoaderEvent ):void { trace( "onCompleteHandler" ); } private function onFailHandler( event : LoaderEvent ):void { trace( "onFailHandler" ); } } }
lewispeel Posted March 28, 2013 Author Posted March 28, 2013 I'm using 1.9 - that's the latest version right?
GreenSock Posted March 28, 2013 Posted March 28, 2013 Nope, that's almost a year old. 1.935 is the latest. You can download it with GSAP (same AS3 zip): http://www.greensock.com/?download=GSAP-AS3
lewispeel Posted March 28, 2013 Author Posted March 28, 2013 Ahh my bad, I was using the SWC I downloaded from; http://www.greensock.com/loadermax/ (the link in the top right) and assumed it was the latest. I'm now seeing event.data! Thanks Jack
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now