Flash - actionscript 2 - HTTP REQUEST
I'm new to flash and it's really bugging me that I cannot find out how to do a simple url request. I don't want to do XML. I just need to read a file ex: example.com/file.txt or example.com/file.php.
I am rocking back with Actionscript 2.0, do开发者_运维百科es anyone know how to do a simple HTTP Request in FLASH, thanks it driving me crazy that I can't find it.
Thank in advance.
Use PHP code for reading from .txt file and than use code like this:
function loadData():Void {
var recive:LoadVars = new LoadVars();
recive.onLoad = function(loading:Boolean):Void {
if (loading) { //if were variables succesfully loaded
trace(unescape(this)); //trace PHP variables
} else {
trace("Error!"); // if wasn't process succesfull, trace error
}
};
var send:LoadVars = new LoadVars();
send.premenna = "text"; // send to $_POST['text'] in php
send.sendAndLoad("www.web.comfile.php", recive, "POST"); //send and load variables
}
_root.tlacitko.onRelease = loadData; //do it after button is pressed
In short, use loadVars for loading php vars. (do not read commentaries....)
The methods for retrieving data over HTTP in ActionScript 2.0 is, as you mention, primarily designed to fetch XML using the XML object or as in FrewCen's answer fetch variable-value pairs using LoadVars. But if you prefer to get hold of the raw data, so to speak, of the HTTP request, you can use LoadVars (or the XML object) and define a listener for the onData event:
http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00001161.html
精彩评论