Sending and receiving data from Flash AS3 to PHP

后端 未结 3 1407
逝去的感伤
逝去的感伤 2020-11-30 09:37

I know this is frequently asked, but I have looked all over the internet to find the mistake I\'m making with the code I\'ve used to send and receive data from AS3 to PHP an

3条回答
  •  离开以前
    2020-11-30 09:45

    Try

    submitbtn.addEventListener(MouseEvent.CLICK, sendData);
    
    function sendData(event:MouseEvent):void
    {
      var urlreq:URLRequest = new URLRequest ("http://[mydomain]/test.php");
      urlreq.method = URLRequestMethod.POST; 
    
      var urlvars:URLVariables = new URLVariables(); 
      urlvars.uname = nametxt.text;
      urlvars.apellido = aptxt.text;
      urlvars.email = emtxt.text;
      urlvars.cedula = cctxt.text;
      urlvars.score = scoretxt.text;
      urlreq.data = urlvars;          
    
      var loader:URLLoader = new URLLoader (urlreq); 
      loader.addEventListener(Event.COMPLETE, completed); 
      loader.dataFormat = URLLoaderDataFormat.VARIABLES; 
      loader.load(urlreq); 
    }
    
    public function completed (event:Event):void{
      var variables:URLVariables = new URLVariables( event.target.data );
      resptxt.text = variables.done;
    }
    

    Updated the completed function... and corrected missing bracket.

提交回复
热议问题