I'm sure this isn't the most elegant code as it's my first time using classes. My problem is that my my custom 'change' event is not being dispatched from place but not the other. If anyone has a suggestion on a more modular way of writing this I'd also appreciate it. Basically, my sendChange function is being called, and the data is being passed through dispatch event, but my listener does not trigger. It never get to the event trigger in my fla, which for the moment is just a trace. Any ideas?
import mx.events.EventDispatcher; class myComboBox { // private var dispatchEvent:Function; private var dispatchQueue:Function; public var addEventListener:Function; public var removeEventListener:Function; public function myComboBox(m:MovieClip, d:XML, c:Number) { //(m)movieclip reference, (d)xml data to fill combobox, (c)default category id to show mx.events.EventDispatcher.initialize(this); _cb = m; _xml = d; _cat = c; //Loop through data and make combobox entries for (var i:Number = 0; i<_xml.firstChild.childNodes.length; i++) { var xn:XMLNode = _xml.firstChild.childNodes[i]; var id:Number = xn.attributes.id; //defaulting action dispatches change if an id exists that's equal to the one passed if (_cat == id) { trace("matched on "+i+" "+_cat+" "+id); sendChange(id); } } private function sendChange(id:Number) { trace("sendChange"); dispatchEvent({target:this, type:"change", parameters:id}); } } //Code from fla: var combo:Object = {}; function init() { my_cmb = new myComboBox(cmb, _xml, 40); my_cmb.addEventListener("open", combo); my_cmb.addEventListener("close", combo); my_cmb.addEventListener("change", combo); } combo.change = function(evt:Object) { trace("changed! idx= "+evt.parameters.idx); } _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com