views:

120

answers:

3

For Actionscript 2.0

Let's say this page

www.example.com/mypage

returns some html that I want to parse in Actionscript.

How do i call this page from Actionscript while getting back the response in a string variable?

A: 

I suppose you could use:

page = getURL("www.example.com/mypage.html");

And it would load the page contents on the page variable.

Marcos Placona
i just need the output of the request, i don't want to load the page.
Dimitris Baltas
I think the page is the output of a request, right? Or maybe I don't understand the question?
Lex
Take a look at the answers of the same question for Actionscript 3 http://stackoverflow.com/questions/2401204/get-output-of-a-webpage-in-actionscript-3
Dimitris Baltas
A: 

use LoadVars():

var lv = new LoadVars();

//if you want to pass some variables, then: lv.var1 = "BUTTON"; lv.var2 = "1";

lv.sendAndLoad("http://www.example.com/mypage.html", lv, "POST");

lv.onLoad = loadedDotNetVars;

function loadedDotNetVars(success) { if(success) { // operation was a success trace(lv.varnameGotFromPage) } else { // operation failed } }

//if you dont want to send data, just get from it, then use just lv.Load(...) instead of sendAndLoad(...)

Ervin
Dimitris Baltas
A: 

I understand. Use this code then:

 docXML = new XML(msg);
    XMLDrop = docXML.childNodes;
    XMLSubDrop = XMLDrop[0].childNodes;
    _root.rem_x = (parseInt(XMLSubDrop[0].firstChild));
    _root.rem_y = (parseInt(XMLSubDrop[1].firstChild));
    _root.rem_name = (XMLSubDrop[2].firstChild);
Ervin
This looks like an answer to a different question.
Dimitris Baltas

related questions