Another way is just to use object.watch on the property:

ModelLocator.watch("user", _changeFunction);


Greetz Erik
 

-----Original Message-----
From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of Alistair McLeod
Sent: woensdag 25 mei 2005 14:37
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Register a ChangeEvent listener on a static
property

Hi Lauren,

I think you're getting things mixed up. Your code should be something
like this (incomplete and untested):

class ModelLocator
{

  static function initialize() : Boolean
  {
    EventDispatcher.initialize( ModelLocator.prototype );

    return true;
  }

  static var mixIn : Boolean = ModelLocator.initialize();

  private static var _user : User;

  [ChangeEvent("userChanged")]
  public static function get user() : User
  {
    return _user;
  }

  public static function set user( user : User ) : Void
  {
    _user = user;
  }
}
        

class AnotherClass
{

  public function AnotherClass()
  {
    ModelLocator.addEventListener( "userChanged", this );
  }

  ...

}

Theres quite a lot going on in there, search the archives for the static
initialization (you can alternatively just use
EventDispatcher.initialize in a constructor), or read this article about
mixins:
http://www.macromedia.com/support/documentation/en/flex/1/mixin/index.ht
ml

You should probably also use the Delegate class in your
addEventListener.

Cheers,

Ali



 
Yahoo! Groups Links

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

<*> 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