语录提交--登陆--注册--论坛交流--站长博客

精简的AS3 remoting

[作者:flashxm][日期:2008-03-21][导航:Flash教程 >> ActionScript3 >> 精简的AS3 remoting]
  

最精简的Flash Remoting实例“Helloworld”,另存为FlashCS3Remoting.as设为Document class即可测试。

  1. package 
  2. {
  3.     import flash.display.MovieClip;
  4.     import flash.net.Responder;
  5.     import flash.net.NetConnection;
  6.  
  7.     public class FlashCS3Remoting extends MovieClip
  8.     {
  9.         private var nc:NetConnection;
  10.         private var rs:Responder;
  11.  
  12.         function FlashCS3Remoting()
  13.         {
  14.             var params:String = ' | Flash CS3 Remoting!';
  15.             rs = new Responder(onResult, onFault);
  16.             nc = new NetConnection;
  17.             nc.connect("http://ubuntu/amfphp/gateway.php");
  18.             nc.call("Helloworld.hello", rs, params);
  19.         }
  20.         private function onResult(result:*):void
  21.         {
  22.             trace(result);
  23.         }
  24.         private function onFault(fault:Object):void
  25.         {
  26.             for (var i in fault) {
  27.                 trace(i + ", " + fault[i]);
  28.             }
  29.         }
  30.     }
  31. }
  1. <?php
  2. class Helloworld
  3. {
  4. function hello($param)
  5. {
  6.     return "Hello World from amfphp" . $param;
  7. }
  8. }
  9. ?>

;) enjoy! 记得修改gateway.

[文章热度:]


上一页:As3.0 xml + Loader应用

下一页:

最新话题

网站导航

搜索

网站公告


Copyright 2007 51as.com. Some Rights Reserved.
鄂ICP备07003189号

Powered by: KingCMS 5.0.1.0217