Amfphpのインストール †Flash側の準備(FlashRemoting?コンポーネントのインストール) †flashremoting_components_flash8_jp.msiをダウンロードし、msiファイルを実行する †参照 : http://www.adobe.com/jp/products/flashremoting/downloads/components/ サーバ側の準備(AMFPHPのインストール) †amfphp-1.2.6.zip(もしくわamfphp-1.9.beta.zip)をダウンロードし、解凍したものを以下のフォルダ構成にしサーバにアップする †参照 : http://amfphp.sourceforge.net/
動作確認 †以下の画面が表示されればインストール成功 http://localhost/amfphp/browser/index.html サンプルの作成 †サーバ側の準備(HelloWorld?.phpを作成する) †ドキュメントルート | |-- amfphp | | | |-- amf-core | |-- browser | |-- services | | |-- HelloWorld.php <?php /** * HelloWorldクラス * * @access public * @package * @author * @version */ class HelloWorld { /** * AMFPHPの設定 * * @access public * @return */ function HelloWorld() { $this->methodTable = array ( "display" => array ( "access" => "remote", "description" => "文字列を返します" ) ); } /** * flashから呼ばれる関数 * * @access public * @return */ function display($string, $name) { return 'Hello world : ' . $name . ' ' . $string; } } Flash側の準備(ActionScript2.0でHelloWorld?.flaを作成する) †import mx.remoting.*; import mx.rpc.*; import mx.remoting.debug.NetDebug; //URL var gatewayUrl:String = "http://localhost/amfphp/gateway.php"; //デバッグの初期化 NetDebug.initialize(); //PHPのHelloWorldクラスを呼ぶ var _service:Service = new Service(gatewayUrl, null, 'HelloWorld', null , null); var pc:PendingCall = _service.display("Hello!", "Bob!!"); pc.responder = new RelayResponder(this, "handleResult", "handleError"); function handleResult(event:ResultEvent) { trace(event.result); } function handleError(event:FaultEvent) { trace("エラー"); } 結果 †HelloWorld?.flaを実行すると、以下のように出力する。 Hello world : Bob!! Hello! Comment †
Counter: 8922,
today: 1,
yesterday: 2
|