Read text message from Php server : Php « Development « Flex






Read text message from Php server

Read text message from Php server
         

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
  layout="vertical" creationComplete="checkMessages();">
  <mx:Script>
    
    import mx.rpc.events.ResultEvent;
    import mx.rpc.http.HTTPService;
    
    private function checkMessages( event:Event = null ) : void {
      var url:String = "http://localhost/aschat/messages.php?t="+((new Date()).valueOf());
      var htMessages:HTTPService = new HTTPService();
      htMessages.url = url;
      htMessages.resultFormat = 'e4x';
      htMessages.addEventListener(ResultEvent.RESULT, onMessages);
      htMessages.send();
    }
    private function onMessages( event:ResultEvent ) : void {
      var messages:Array = [];
      for each( var msg:XML in event.result..message ) {
        messages.push( { user: msg.@user, message: msg.valueOf() } );
      }
      dgMessages.dataProvider = messages;
    
    }
    
  </mx:Script>
  <mx:DataGrid id="dgMessages" width="100%" height="100%">
    <mx:columns>
      <mx:DataGridColumn width="100" dataField="user" headerText="" />
      <mx:DataGridColumn dataField="message" headerText="" />
    </mx:columns>
  </mx:DataGrid>
</mx:Application>

   
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Send text message to a Php serverSend text message to a Php server
2.Call Php pageCall Php page