Hi All , 

Sorry for the late reply , i have been told to send the working code for me and 
here is it below , it might be complicated but this is what i have right now , 

Thanks "Tracy Spratt" <tspr...@...> nts333rd  for your advise , 

i welcome ur suggest i ll try to test ur way , what i need is to get the 
elements returned by the xml from the servlet one by one and the below code did 
that but anyhow i ll test your way ...

thanking all ...

here is the current working code


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"; layout="absolute" 
creationComplete="init()">
<mx:Script>
<![CDATA[
import flash.net.sendToURL;
import mx.controls.Alert;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;
import mx.rpc.xml.SimpleXMLDecoder;
import mx.controls.Button;
import mx.controls.Label;
import mx.collections.ArrayCollection;
import mx.rpc.http.HTTPService;
import mx.rpc.events.FaultEvent;
import mx.rpc.events.ResultEvent;

[Bindable]
public var expenses:ArrayCollection;

public var userId:int;

public var servletURL:String;
public var topSenders:HTTPService;

private function init():void{
userId = 12;
useHttpService();
}

public function useHttpService():void {
                
                topSenders = new HTTPService();
                topSenders.url = 
"http://localhost:8080/Application/topSenderServlet?USER_ID="+userId.toString();
                topSenders.method = "POST";
                topSenders.addEventListener("result", resultHandler);
                topSenders.addEventListener("fault", faultHandler);
                topSenders.useProxy=false;
                topSenders.resultFormat="e4x";
                topSenders.send();
                
                topSenders.disconnect();
                topSenders.clearResult(true);
                topSenders = null;
                topSenders.logout();
                
                }


public function resultHandler(event:ResultEvent):void {
                trace("resultHandler invoked");
                var xmlStr:String = event.result.toString();
            var xmlDoc:XMLDocument = new XMLDocument(xmlStr);
        var decoder:SimpleXMLDecoder = new SimpleXMLDecoder(true);
        var resultObj:Object = decoder.decodeXML(xmlDoc);
       
        
        
       
        for(var i:int=0;i<resultObj.linkinscreen.topsenders.sender.length;i++){
                Alert.show(resultObj.topsenders.sender[i].phone);

                
        }
         
                
        }
public function faultHandler(event:FaultEvent):void {
                trace("faultHandler Invoked");
                Alert.show('Oops there is a problem!....' + 
event.fault.message);
        }

]]>
</mx:Script>
</mx:Application>

Reply via email to