티스토리 뷰

/has3/H_config.as
package has3
{
 import flash.events.Event;
 import flash.events.EventDispatcher;
 
 import mx.controls.Alert;
 import mx.rpc.events.FaultEvent;
 import mx.rpc.events.ResultEvent;
 import mx.rpc.http.HTTPService;
 
 public class H_config extends EventDispatcher
 {
  public var webServer:String;
  public var dbServer:String;
  public var dbName:String;
  public var dbId:String;
  public var dbPass:String;
  
  private var stmp:String;
  
  public function H_config(surl:String)
  {
   var hs:HTTPService = new HTTPService();
   
   hs.addEventListener(ResultEvent.RESULT,resultEvent);
   hs.addEventListener(FaultEvent.FAULT,faultEvent);
   hs.url = surl
   hs.send();
   stmp = surl; 
  }
  //--------------------------------------------------------------------------------------------
  //서버에서 XML 환경화일 읽어오는 이벤트 
  //--------------------------------------------------------------------------------------------
  private function resultEvent(event:ResultEvent):void
  {
   webServer = event.result.config.rec.webServer;  
   dbServer = event.result.config.rec.dbServer;  
   dbName = event.result.config.rec.dbName;  
   dbId = event.result.config.rec.dbId;  
   dbPass = event.result.config.rec.dbPass;
    
   dispatchEvent(new Event("H_configEvent",false,false));    
    
  }
  private function faultEvent(event:FaultEvent):void
  {
   Alert.show("'" + stmp + "' 환경화일을 읽어오지 못했습니다.!");
  }
 }


H_config.xml

 
  172.16.10.10
  172.16.10.10
  watercom
  root
  hksxxx
 


[호출 사용방법]
 import has3.H_config;
 public var CFG:H_config;   
 
 CFG = new H_config("http://localhost/WATERCOMtm/load_dat/H_config.xml");
 CFG.addEventListener("H_configEvent",resultCFG);
 
 private function resultCFG(evt:Event):void
 {
  Alert.show(CFG.webServer);
 }