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" <[email protected]>
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);
> }
> }
> }
>


_______________________________________________
[email protected]
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

Reply via email to