RE: [Flashcoders] dispatchEvent within another event handler
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
RE: [Flashcoders] dispatchEvent within another event handler
yeah. maybe it should be _service = new MyService(); _service.addEventListener(xmlLoaded, doSomething); David Ngo [EMAIL PROTECTED] wrote: 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 - The fish are biting. Get more visitors on your site using Yahoo! Search Marketing. ___ 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
Re: [Flashcoders] dispatchEvent within another event handler
good god I'm a moron. thanks guys On May 23, 2007, at 8:31 AM, Adrian Ionut Beschea wrote: yeah. maybe it should be _service = new MyService(); _service.addEventListener(xmlLoaded, doSomething); ___ 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
Re: [Flashcoders] dispatchEvent within another event handler
You're listening for an event on the view, which doesn't dispatch that event. The event is dispatched from the service, to which you never subscribe. regards, Muzak - Original Message - From: Sam [EMAIL PROTECTED] To: Flashcoders mailing list flashcoders@chattyfig.figleaf.com Sent: Wednesday, May 23, 2007 1:46 PM 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
Re: [Flashcoders] dispatchEvent within another event handler
That's not how bubbling works. Bubbling only occurs for objects that are on the display list. http://livedocs.adobe.com/flash/9.0/main/0137.html regards, Muzak - Original Message - From: Sam [EMAIL PROTECTED] To: flashcoders@chattyfig.figleaf.com Sent: Wednesday, May 23, 2007 2:31 PM Subject: Re: [Flashcoders] dispatchEvent within another event handler Why is that a problem if bubbling is set to true? On May 23, 2007, at 8:06 AM, David Ngo wrote: You're listening for an event from your view class that's being fired from your service class, that's why. ___ 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