错误#2101不明白为什么

时间:2015-12-03 00:07:58

标签: php actionscript-3 flash

所以我有一个AS3代码将变量发送到PHP页面。

这是我的AS3代码:

function sendData(evt:Event):void {
    // Create a new URLRequest instance sending data to "ascom01.php"
    var urlReq:URLRequest = new URLRequest ("http://www/***/***/script.php");

    // Send data using the POST method
    urlReq.method = URLRequestMethod.POST; 

// The data property of the request is set to the
    // URLVariables instance (myVariables) to send to the PHP file.
    // Note: myVariables stored the variable (e.g. candidate)
    var urlVars:URLVariables = new URLVariables(); 

    urlVars.theport = mySharedObject.data.theCity;
    trace(urlVars.theport);
    urlReq.data = urlVars;  
    trace(urlReq.data);

    // Create a new instance of the URLLoader class to work with.
    // URLLoader.load( ) method should be used when we need the 
    // sent variables returned back to Flash ActionScript.

    var loader:URLLoader = new URLLoader (urlReq); 
    //specify dataFormat property of the URLLoader to be "VARIABLES"
    //This ensure that the variables loaded into Flash with the same variable names
    loader.dataFormat = URLLoaderDataFormat.VARIABLES; 

    //Load the PHP file by using URLRequest

    loader.load(urlReq); 
    //Listen when the loading of data COMPLETE
    //Call the loadComplete function when the loading COMPLETE
    loader.addEventListener(Event.COMPLETE, loadComplete);
}

trace(urlReq.data);输出:theport=Thio

在我的php页面中,我有:

$theport = $_POST['theport'];

但是每次在我的AS3中触发sendData函数时,我都会遇到这个错误:

Error: Error #2101: The String passed to URLVariables.decode() must be a URL-encoded query string containing name/value pairs.
    at Error$/throwError()
    at flash.net::URLVariables/decode()
    at flash.net::URLVariables()
    at flash.net::URLLoader/onComplete()

因此之前存在此问题,因此未调用loadComplete。知道是什么原因引起的吗?

很多,

0 个答案:

没有答案