I just ran into this the other day, and I created a public static variable
in the class called "instance". When the static class is initialized via
some sort of init() function, I create a sole, empty instance of the class
whose only role is to dispatch events. Thus, when I have to assign a
listener, I assign it to the instance, for example:

public static var instance:SingletonClass
...
public function SingletonClass() {

}
...
public static function init():void {
    instance = new SingletonClass();
}

then,  to add event listener
SingletonClass.instance.addEventListener(SingletonClass.EVENT_NAME,
listenerFunction);

I'd love to hear about drawbacks to this approach. I'm sure there are some
issues, and this was a new problem/idea.

-jonathan

On Thu, May 22, 2008 at 12:16 PM, Stephen Ford <[EMAIL PROTECTED]> wrote:

> Is there anyway for a static function within a class to fire off an event?
> assuming the static function exists within a class that has no constructor
> (ie: is never instantiated).
>
> As I understand it, for another object to  be listening for the event, said
> object must have a local refence to the class doing the dispatching?
>
> Anyway around this.
>
> SF.
>
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>



-- 
-jonathan howe :: 404.434.2321 :: 180 High St Apt 26 Portland, ME 04101
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Reply via email to