Flash-actionscript 2-HTTP请求
我是flash新手,我不知道如何做一个简单的url请求,这让我很烦恼。我不想使用XML。我只需要读取一个文件,例如example.com/file.txt或example.com/file.php 我正在使用ActionScript2.0,有人知道如何在FLASH中执行一个简单的HTTP请求吗,感谢它让我抓狂,因为我找不到它Flash-actionscript 2-HTTP请求,flash,http,request,actionscript-2,Flash,Http,Request,Actionscript 2,我是flash新手,我不知道如何做一个简单的url请求,这让我很烦恼。我不想使用XML。我只需要读取一个文件,例如example.com/file.txt或example.com/file.php 我正在使用ActionScript2.0,有人知道如何在FLASH中执行一个简单的HTTP请求吗,感谢它让我抓狂,因为我找不到它 提前感谢。使用PHP代码读取.txt文件,然后使用如下代码: function loadData():Void { var recive:LoadVars = new Lo
提前感谢。使用PHP代码读取.txt文件,然后使用如下代码:
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
简而言之,使用loadVars加载php变量。(不要阅读评论…)使用PHP代码读取.txt文件,然后使用如下代码:
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
简而言之,使用loadVars加载php变量。(不要阅读评论…)正如您所提到的,ActionScript 2.0中通过HTTP检索数据的方法主要设计为使用XML对象获取XML,或使用LoadVars获取FrewCen的答案中的变量-值对。但是,如果您希望获得原始数据,也就是HTTP请求的原始数据,则可以使用LoadVars(或XML对象)并为onData事件定义侦听器:
正如您所提到的,ActionScript 2.0中通过HTTP检索数据的方法主要设计为使用XML对象获取XML,或者使用LoadVars获取FrewCen的应答-获取变量-值对。但是,如果您希望获得原始数据,也就是HTTP请求的原始数据,则可以使用LoadVars(或XML对象)并为onData事件定义侦听器: