tags:

views:

279

answers:

2

I want to call a web page from Flash and use the data returned from it (either in plain text or XML). I see with the NetConnection you can connect to a web service, but I just want to call a plain old web page.

It seems like I managed to do this a while back, but for the life of me, I can't find the answer on the web. Does anyone know what the function / code is to call a web page in Flash and get the data back?

Thanks,

+1  A: 

Well, if you're using AS3 then you'll want to use the URLLoader class. One common mistake using URLLoader is that you need to pass it an instance of URLRequest like so:

var loader:URLoader = new URLLoader();
loader.load(new URLRequest("http://www.stackoverflow.com"));

Note that you use the URLRequest object to specify and GET/POST parameters you want to send so in that case you want to build the URLRequest separately rather than inline.

Branden Hall
+2  A: 

All you need to do is use a URLLoader.

var urlRequest:URLRequest= new URLRequest("http://example.com/page/");
_urlLoader = new URLLoader();
_urlLoader.addEventListener(Event.COMPLETE, onXMLDataLoaded, false, 0, true);
_urlLoader.load(urlRequest);


function onXMLDataLoaded(evt:Event):void {   
    var xml = new XML(_urlLoader.data);
}
Alex Jillard
I'm an idiot. I was looking at this far more complicated that I needed to.
Ryan Smith