thanks for the quick response. If you view the source for MM's EventDispatcher you'll see that it traverses the event listeners array with a for..i..in. This is so that one of the listening methods can "removeEventListener" and not screw up the array mid-process. A for..i..in simply hits every uniqe property despite order or number.
The code I sent is an illustritive example. I've resolved my EventDispatcher, but I'm finding this issue is the case in other circumstanced (states, for example, are changing the frames while a for..i..in loop is running on that object). Tyler On 5/9/06, Kevin Newman <[EMAIL PROTECTED]> wrote:
Logically it seems as though a list of listeners should be in an array, instead of a collection of object properties, but to each his own :-) You seem to have a small typo in here: for (var i in listeners) { dispatch(listeners[i].event); { The second curly bracket is backwards. I don't know if that is causing your problem though, could you give information? Also, there is an mx object that can do event dispatching/management/delegation: mx.events.EventDispatcher http://livedocs.macromedia.com/flash/mx2004/main_7_2/wwhelp/wwhimpl/common/html/wwhelp.htm?context=Flash_MX_2004&file=00002443.html Kevin N. Tyler Wright wrote: > I have sevaral for (var i in .. ) loops running looping through > objects that > get thrown (interupted OR actually go forever) when I change the frame > of a > movieClip where one exists. > > Just as an example: > > for (var i in listeners) > { > dispatch(listeners[i].event); > { > > // the listener > function setState() > { > this.gotoAndStop("over"); > } > > or so, produced and endless loop (when the "listeners" object was > defined on > the movieClip using the for .. i .. in) > > Anyone have any ideas on fixes? I changed my listener to loop through > it as > an Array (which isn't as fast and doesn't allow you to remove listening > objects halfway through the process). I've run into a circumstance > where I > can't use an Array. > > Tyler _______________________________________________ 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
_______________________________________________ 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