两种好用的方式获取远程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)"  />
 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值