Jump to content
Search Community

Recommended Posts

Posted

Hi,

 

Is there a way to grab the response headers from the LoaderEvent?

 

Thanks, Lewis

Posted

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. 

Posted

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!!

Posted

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" );
		}
	}
}

 

 

Posted

What version of LoaderMax are you using?

Posted

I'm using 1.9 - that's the latest version right?

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...