0

AS3には、PHPファイルを頻繁に呼び出す関数があります。それは失敗し、タイトルで使用したエラーをスローします。私はいつもこのエラーメッセージを受け取ります。しかし、ブラウザで実行すると正常に動作します。何が問題なのかわかりません。これが私のコードです。

    $function checkComplete(evt:MouseEvent):void {

    // Create A new URLVariables instance to store the variable
    var myVariables:URLVariables = new URLVariables();

    // Create a variable (e.g. username) to send
    myVariables.username = candidate_txt.text;

// Create a new URLRequest instance sending data to "ascom01.php"
var myRequest:URLRequest = new URLRequest("apm01.php");

// Send data using the POST method
myRequest.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)
myRequest.data = myVariables;

// 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 myLoader:URLLoader = new URLLoader;

//specify dataFormat property of the URLLoader to be "VARIABLES"
//This ensure that the variables loaded into Flash with the same variable names
myLoader.dataFormat = URLLoaderDataFormat.VARIABLES;

//Load the PHP file by using URLRequest
myLoader.load(myRequest);

//Listen when the loading of data COMPLETE
//Call the loadComplete function when the loading COMPLETE
myLoader.addEventListener(Event.COMPLETE, loadComplete);

}

// Hook up the button with the function checkComplete
enter_btn.addEventListener(MouseEvent.CLICK, checkComplete);

// This is the function that display the data returned back from PHP file
function loadComplete(evt:Event):void {

//Display the value with variable name "totalItem"
total_txt.text = evt.target.data.totalItem

//Get the value (string) with variable name "phpConfirm"
var myResult:String = evt.target.data.phpConfirm;

//Split the string into an Array
var myArray:Array = myResult.split("|");
//output_txt.text = "The number of items are: " + myArray.length;

var finalString = "";
var i:int;
for (i = 0; i < myArray.length; i++) {

finalString = finalString + myArray[i] + "<br>";
    }

    output_txt.htmlText = finalString;


    }`
4

2 に答える 2

0

この例外は、phpファイルをphp-serverにデプロイする必要があるために発生します。Flashはphpコードを実行できませんでした。ディスクCから起動しようとしています。

それで

var myRequest:URLRequest = new URLRequest("apm01.php");

次のようなものにする必要があります

var myRequest:URLRequest = new URLRequest("http://myhost:80/example/apm01.php");

または、フラッシュファイルをサーバー上の同じフォルダーにアップロードし、そこから起動することもできます。

于 2012-08-21T11:13:45.713 に答える
0

私の解決策はおそらくこのボードの他の人にとって明白なものでした...しかし私はこれについて無知でした:

FlashファイルからリンクしていたPHPファイルは、サーバー上に作成した新しいファイルでした。標準の666権限がありました。権限を644に設定すると、すべてがうまく機能しました。

于 2013-01-30T16:22:21.067 に答える