两种好用的方式获取远程xml数据

<mx:Script>
		<![CDATA[
          import flash.net.navigateToURL;        
          private var downloadURL:URLRequest;  
          private var file:FileReference;  
    	  import flash.net.URLStream;    
    	  import mx.controls.Alert;
    	  import mx.collections.ArrayCollection;     
          import mx.rpc.events.ResultEvent;     
          import mx.utils.ObjectProxy;  
          private var DownLoadfile:FileReference; //这是要主要的地方
   [Bindable]     
        private var list:ArrayCollection=new ArrayCollection();   
           [Bindable]     
        private var list2:ArrayCollection=new ArrayCollection();   
         [Bindable]
     public var i:int = 0;  
   
                             private function xmlHandle(evt:ResultEvent):void
                             {
                     


                              //    good2.text = list[3].name+"@@@@@@";   //ok
                           
                            	list=evt.result.files.file;  //结果集存到list中,下面调用
                             }
//                                 

function display(event:Event):void{
 
//good5.text= String(service.lastResult);

}


	private function init():void{
		
	
	service.send();
		
	var url:URLRequest=new URLRequest("http://172.20.32.60:8080/new/tt");    
     var loader:URLLoader=new URLLoader();     
     loader.addEventListener(Event.COMPLETE, handleURLLoaderCompleted);     
     loader.load(url);    	
  }  
  private function handleURLLoaderCompleted(event:Event):void {  
    var loader:URLLoader = event.target as URLLoader;  
     var xml:XML = XML(loader.data);  
     // good7.text=xml.file[2].name+"^^^^^^^^^^@@@";    //ok
      //xml中调用
  }
		    private function readFiles(urlAdd:String):void{

		//
   //  navigateToURL(new URLRequest("http://172.20.32.60:8080/new/download?url="+urlAdd), "_blank"); 
           text1.text=file.toString()+"*******";
    
		    }
		 
		 private function downLoadZip():void{
		 
		  downloadURL = new URLRequest("http://172.20.32.60:8080/new/download?url=zip"); 
            file = new FileReference(); 
            configureListeners(file); 
            file.download(downloadURL,"log.zip"); 

		 
		 }

            private function downLoadFiles(urlAdd:String):void{  
            downloadURL = new URLRequest("http://172.20.32.60:8080/new/download?url="+urlAdd); 
            file = new FileReference(); 
            configureListeners(file); 
            file.download(downloadURL,urlAdd); 

		    }
		    
		    
		    private function configureListeners(dispatcher:IEventDispatcher):void {
		        dispatcher.addEventListener(Event.COMPLETE, completeHandler);
		
		    }
    
		    private function completeHandler(event:Event):void {
		    	mx.controls.Alert.show("文件下载成功");
		    }
           
		]]>
	</mx:Script>
	
	<mx:HTTPService id="service" url="http://172.20.32.60:8080/new/tt" result="xmlHandle(event)"  />
 

你可能感兴趣的:(xml,.net,Flash)