I think what you're looking for is a Singleton class that extends 
EventDispatcher which only purpose is to be able to add listeners 
to and dispatch events upon.

package com.muzakdeezign.mvc.managers {
 import flash.events.EventDispatcher;
 public class SystemEventManager extends EventDispatcher {

  private static var __instance:SystemEventManager = null;

  public function SystemEventManager() {
   if(__instance != null) {
    throw new Error("Instance of SystemManager already exists. Use 
SystemManager.getInstance()");
   }
  }

  public static function getInstance():SystemEventManager {
   if(__instance == null ) {
    __instance = new SystemEventManager();
   }
   return __instance;
  }
 }
}

//from anywhere in your app:

import com.muzakdeezign.mvc.managers.SystemEventManager;

SystemEventManager.getInstance().addEventListener("someEvent", 
someEventHandler);

//and somewhere else in your app
SystemEventManager.getInstance().dispatchEvent(new Event("someEvent"));

Make sense?

regards,
Muzak

----- Original Message ----- 
From: "bithroop" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, November 29, 2007 5:33 PM
Subject: [flexcoders] Re: Events and Non-Display Objects


Jehanzeb - first, thank you for the detailed response! I really
appreciate it.

In the code you provided, the CustomEventDispatcher was instantiated
within the mx:Application object. So from what I've seen, yes
Application will be able to hear CustomEventDispatcher's events.

However, my sitation is more like:

Application
|
|------>ContainerC->ContainerD
|
|------>ContainerA->Custom AS class not in display
list->CustomEventDispatcher.

And I want CustomEventDispatcher's event to be heard by Container D.
Right now I have my listener on Application, and then Application is
calling a method on ContainerC, which is then calling a method on
ContainerD. This seems to be ugly and bad form.




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to