///////////////////////////////////////////////////////////////////////////////// // Copyright (C) 2010 Wolfgang Kowarschick // // Permission is granted to copy, distribute and/or modify this document // under the terms of the WK License, Version 1.0 (WKL 1.0) or any later // version published by Wolfgang Kowarschick. ///////////////////////////////////////////////////////////////////////////////// package as3.xml.service { import as3.assert.Assert; import as3.xml.data.I_DataXML; import flash.events.Event; import flash.net.URLLoader; import flash.net.URLRequest; public class ServiceXML implements I_ServiceXML { ///////////////////////////////////////////////////////////////////////////// // LDVCS ///////////////////////////////////////////////////////////////////////////// private var v_data: I_DataXML; public function set data(p_data: I_DataXML): void { if (v_data != p_data) { Assert.equals(v_data, null, this, "data has already been initialized"); Assert.notEquals(p_data, null, this, "data cannot be set to null"); v_data = p_data; }; } ///////////////////////////////////////////////////////////////////////////// // Constructor ///////////////////////////////////////////////////////////////////////////// public function ServiceXML(p_data: I_DataXML = null) { this.data = p_data; } ///////////////////////////////////////////////////////////////////////////// // Methods ///////////////////////////////////////////////////////////////////////////// public function load(p_url: String): void { var l_request: URLRequest = new URLRequest(p_url); var l_loader: URLLoader = new URLLoader(); l_loader.addEventListener(Event.COMPLETE, o_url_loaded); l_loader.load(l_request); } private function o_url_loaded(p_event: Event): void { v_data.xml = XML(URLLoader(p_event.target).data); } ///////////////////////////////////////////////////////////////////////////// // End of class ///////////////////////////////////////////////////////////////////////////// } } ///////////////////////////////////////////////////////////////////////////////// // End of file /////////////////////////////////////////////////////////////////////////////////