flashとjavascriptとphpでやりとりするには

flashとjavascriptのやり取りは「ExternalInterface」を使う。

JAVASCRIPT:
[sourcecode language=”js”]
function getJavascript()
{
var obj = new Object();
obj.infoTitle = document.URL;
obj.infoUrl = document.title;
}
[/sourcecode]

ACTIONSCRIPT:
[sourcecode language=”js”]
import flash.external.*;

if(ExternalInterface.available)
{
infoObj = ExternalInterface.call(“getJavascript”);
title.text = infoObj.infoTitle;
url.text = infoObj.infoUrl;
}
else
{
title.text = “ExternalInterfaceを利用することが出来ません”;
}
[/sourcecode]
javascriptからのデータがinfo.objの中に格納される。

続いて、flashとphpのやり取りは「sendAndLoad」を使う。
[sourcecode language=”php”]

[/sourcecode]

[sourcecode language=”php”]
//—–[送受信オブジェクトのインスタンス化]
var loadLV:LoadVars = new LoadVars();
var sendLV:LoadVars = new LoadVars();

//—–[渡したい変数名と値を定義]
sendLV.message = “hoge”;

//—–[コールバック関数を定義]
loadLV.onLoad = function(success)
{
if (success == true)
{
trace(loadLV.responce);
}
else
{
trace(“通信エラー”); //hogeをflashに返します”
}
}

//—–[sendAndLoadメソッドを使ってデータの送受信を行う]
sendLV.sendAndLoad(“phpファイルのパス”, loadLV, “POST”);

[/sourcecode]