从配置文件中获取数据

//the following is a piece of simple code for assessing the xml config file in the project

package 

    import flash.xml.XMLDocument; 
    
    public class ConfigLoader 
    { 
        import flash.events.Event; 
        import flash.net.URLLoader; 
        import flash.net.URLRequest; 
        import mx.controls.Alert;   

        public function ConfigLoader() 
        { 
        }

        public function initComplete():void 
        { 
          loader.load(request); 
          loader.addEventListener(Event.COMPLETE, onComplete);         
        }

        public function onComplete(event:Event):void 
        { 
          var loader1:URLLoader = event.target as URLLoader; 
          if (loader1 != null) 
          { 
             urlString = loader1.data; 
             xml  = new XMLDocument(); 
             xml.parseXML(loader1.data);

          } 
          else 
          { 
               Alert.show("loader is not a URLLoader!"); 
          } 
        }  
         
         
        public var projectColor:GCColor; 
        
        private var loader:URLLoader = new URLLoader(); 
        private var request:URLRequest = new URLRequest("../src/FlexUrl.properties"); //this file location should be changed according to your project 
        private var urlString:String; 
        public var xml:XMLDocument; 
    } 
}

你可能感兴趣的:(xml,function,String,File,Class,import)