/* * @author Galaburda Oleg a_[w] * http://actualwave.com/ * */ /* Можно вместо EventDispatcher'а в XMLCover использовать его XMLNotifier, а для XMLList можно вставить цыкл. */ package aw.xml{ import aw.events.XMLEvent; import flash.events.EventDispatcher; import flash.utils.Dictionary; [Event(name="changed", type="aw.events.XMLEvent")] public class XMLNotifier extends EventDispatcher{ static private const _instances:Dictionary = new Dictionary(true); static private var _privater:XMLNotifierPrivater; protected var _xml:XML; public function XMLNotifier(x:XML, prv:XMLNotifierPrivater):void{ super(); _xml = x; _instances[_xml] = this; _xml.setNotification(notificationHandler); } public function get xml():XML{ return this._xml; } protected function notificationHandler(targetCurrent:Object, command:String, target:Object, value:Object, detail:Object):void{ var e:XMLEvent = new XMLEvent(command, targetCurrent, target, value, detail, XMLEvent.CHANGED); this.dispatchEvent(e.convertToSpecifiedForm()); this.dispatchEvent(e); } static public function getInstance(xml:*):XMLNotifier{ var inst:XMLNotifier; if(xml is XMLList) xml = xml[0]; if(xml){ if(xml in _instances) inst = _instances[xml]; else{ var dict:Dictionary = _instances; for(var p:* in dict){ if(p===xml){ inst = _instances[p]; break; } } } if(!inst){ if(!_privater) _privater = new XMLNotifierPrivater(); inst = new XMLNotifier(xml, _privater); } } return inst; } } } class XMLNotifierPrivater{ function XMLNotifierPrivater(){ } }