Return to Snippet

Revision: 33931
at October 15, 2010 17:07 by ddtfish


Updated Code
//�root.xml中读�status,a����������询xml
public static  function readStatus(a:String):ArrayCollection{
                var xml:XML;
                var xmlList:XMLList;
	var xmlLoader:URLLoader = new URLLoader();
				
	var arr:ArrayCollection = new ArrayCollection();
	xmlLoader.load(new URLRequest("pb/utils/root.xml"));
				
	xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
				
	function xmlLoaded(event:Event):void
	{
	        xml = XML(event.target.data);
	        //��scope��
	     xmlList = xml..userStatus.(@scope==a);
	        //trace(xmlList[0][email protected]);
	       for(var i:int = 0; i < xmlList.length(); i++)
	      { 
     	      //�xmlList转�为object类�
		var o:Object = new Object();
		o.label = xmlList[i][email protected];
		o.data = xmlList[i][email protected]; 
		arr.addItemAt(o,i);		    	
						
	      }    
	}
	return arr;
            }

Revision: 33930
at October 15, 2010 00:59 by ddtfish


Initial Code
//从root.xml中读取status,a是参数,用来选择性查询xml
public static  function readStatus(a:String):ArrayCollection{
                var xml:XML;
                var xmlList:XMLList;
	var xmlLoader:URLLoader = new URLLoader();
				
	var arr:ArrayCollection = new ArrayCollection();
	xmlLoader.load(new URLRequest("pb/utils/root.xml"));
				
	xmlLoader.addEventListener(Event.COMPLETE, xmlLoaded);
				
	function xmlLoaded(event:Event):void
	{
	        xml = XML(event.target.data);
	        //选择scope属性
	     xmlList = xml..userStatus.(@scope==a);
	        //trace(xmlList[0][email protected]);
	       for(var i:int = 0; i < xmlList.length(); i++)
	      { 
     	      //把xmlList转化为object类型
		var o:Object = new Object();
		o.label = xmlList[i][email protected];
		o.data = xmlList[i][email protected]; 
		arr.addItemAt(o,i);		    	
						
	      }    
	}
	return arr;
            }

Initial URL


Initial Description
As3 load from XML----------------------

Initial Title
As3 load from XML

Initial Tags


Initial Language
ActionScript 3