You're listening for an event from your view class that's being fired from your service class, that's why.
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Sam Sent: Wednesday, May 23, 2007 7:46 AM To: Flashcoders mailing list Subject: [Flashcoders] dispatchEvent within another event handler I'm trying to do what i think should be pretty simple. I want to dispatch an event when my xml has completed lodaing. For the life of me i can't figure out why event does not get dispatched from "handleXML", I know the listner works because I've tested it by dispatching the same event from a button click. Any ideas what I may be doing wrong? package { import flash.display.Sprite; import com.acme.AppController; import com.acme.MyService; public class MyView extends Sprite { public function MyView() { var controller:MyController = new MyController(this); } } } package com.acme { import flash.events.EventDispatcher; import flash.events.Event; import flash.display.Sprite; import com.acme.MyService; public class MyController extends EventDispatcher { private var _view:Sprite; private var _service:MyService; public function MyController(target:Sprite){ _view = target; _view.addEventListener("xmlLoaded", doSomething); _service = new MyService(); } public function doSomething(e:Event):void{ trace("doSomething CALLED"); } } } package com.acme { import flash.events.EventDispatcher; import flash.events.Event; import flash.net.URLLoader; import flash.net.URLRequest; public class MyService extends EventDispatcher { private var _loader:URLLoader; private var _xml:XML; public function MyService(){ _loader = new URLLoader(); _loader.addEventListener(Event.COMPLETE, handleXML); _loader.load(new URLRequest("xml/data.xml")); } public function handleXML(event:Event):void{ dispatchEvent(new Event("xmlLoaded", true)); // this never fires _xml = new XML(_loader.data); } } } _______________________________________________ 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