views:

492

answers:

3

I am working on an Actionscript 2 project - trying to use the XML object to find a url which is returned as a 302 redirect. Is there a way to do this in actionscript 2?

code:

var urlone:XML = new XML();
urlone.load("http://mydomain.com/file.py");
urlone.onLoad = function (success) {
    trace("I want to print the 302 redirect url here, how do I access it?");
};
A: 

I don't think it's possible from AS2, I think the browser will redirect to the new URL automatically & just return the data from that URL. It may be possible in AS3, they added several new features such as reading HTTP headers and so on.

Perhaps what you should do is instead of returning a 302 redirect, just return the URL as a text string. Then it would be easy to read from within Flash, just use .onData instead of .onLoad so it doesn't try to parse the XML.

davr
A: 

I don't think it's possible (at least using the XML class). It has an onHTTPStatus event handler but it seems that even with that, you'll only be able to access the status code and nothing else.

hasseg
Is there a more appropriate class to make a general HTTP request that would allow me to access the redirect url? Like a netconnection or something?
hasseg
A: 

http://www.arpitonline.com/blog/?p=140