1 Reply Latest reply on Sep 15, 2009 11:28 PM by alex900420

    amfphp problem

    alex900420

      Excuse!

      There is an odd problem in my application.I created a flea market with Flex and PHP, .The framework is pureMVC. AMFPHP is used to communicate with php.

      There are two Proxy which use amfphp to get or send data.One is "LoginProxy" another is "PostInfoProxy".The code in LoginProxy can communicate with the phpfile. but the PostInfoProxy's code can't run through they are almost same.

       

      When run "myService.sayHello.send()", only the Cursor changed state to busy and didn't disappear.

       

      Code-- “PostInfoProxy”

      package model
      {
      import model.vo.PostInfoVo;

      import mx.controls.Alert;
      import mx.rpc.events.FaultEvent;
      import mx.rpc.events.ResultEvent;
      import mx.rpc.remoting.mxml.RemoteObject;
      import notification.*;
      import org.puremvc.as3.interfaces.IProxy;
      import org.puremvc.as3.patterns.proxy.Proxy;

      import view.*;

      //使用amfphp与后台数据库交互,获取info数据
      public class PostInfoProxy extends Proxy implements IProxy
      {
        public static const NAME:String = "PostInfoProxy";
        public static const POST_INFO_SUCCESS:String= "postInfosuccess";
           public var title:String;
           private var myService:RemoteObject;

           public function PostInfoProxy():void
           {
            //Alert.show("Proxyinit","Proxyinit");
            myService =  new RemoteObject("amfphp");
         myService.showBusyCursor = true;
         myService.source="PostInfoService";
         myService.endpoint="http://localhost/amfphp/gateway.php";
         myService.AddEventListener(FaultEvent.FAULT, faultHandler);
         myService.addNote.addEventListener(ResultEvent.RESULT, addResHandler);
         myService.sayHello.addEventListener(ResultEvent.RESULT, addResHandler);
         //myService.channelSet
         Alert.show(myService.toString(), "test");
           }
        public function postinfo():void
        {
                  //title = Vo.postinfo_title;
                  Alert.show("title", "postinfo");
                  //myService.addNote.send("title","asd");         
                  myService.sayHello.send("AlexYang");
        }

        public function faultHandler(evt:FaultEvent):void
        {
         Alert.show(evt.fault.message,"Error");
        }

              public function addResHandler(evt:ResultEvent):void
              {
               Alert.show(evt.result.toString(), "test");
              }

      }

      }

       

      code-- “LoginProxy”

      package model
      {

      import model.vo.LoginVo;

      import mx.controls.Alert;
      import mx.rpc.events.FaultEvent;
      import mx.rpc.events.ResultEvent;
      import mx.rpc.remoting.mxml.RemoteObject;

      import org.puremvc.as3.interfaces.IProxy;
      import org.puremvc.as3.patterns.proxy.Proxy;

      public class LoginVoProxy extends Proxy implements IProxy
      {
        public static const NAME:String = 'loginVoProxy';
        public static const LOGIN_SUCCESS:String = 'loginSuccess';
        public static const LOGIN_FAILED:String = 'loginFailed';
       
        private var myService:RemoteObject;
       
        public function LoginVoProxy():void
        {
         myService = new RemoteObject("amfphp");
         myService.showBusyCursor = true;
         myService.source = "Admin.functions";
         myService.endpoint = "http://localhost/amfphp/gateway.php";
         //出现错误
         myService.addEventListener(FaultEvent.FAULT, faultHandler);
         myService.login.addEventListener(ResultEvent.RESULT, loginHandle);
         Alert.show(myService.toString(), "test");  
        }

        //返回错误的处理
        internal function faultHandler(evt:FaultEvent):void
        {
         Alert.show(evt.fault.message,"Error");
        }

       
        public function loginHandle(evt:ResultEvent):void
        {
         //Alert.show("loginHandle");
         var result:String = evt.result.toString();
         if(result)
         {
          Alert.show(result, "ok");
         }
         else
         {
          Alert.show("false");
         }
        
        }
       
        public function login(loginVo:LoginVo):void
        {
         //Alert.show(loginVo.ToString(), "test");
         myService.login.send(loginVo.username,loginVo.password);
        }

      }
      }