4 Replies Latest reply on Feb 19, 2009 5:30 PM by Newsgroup_User

    Setter/getter does not fire

    justria Level 1
      Hi,

      in a class CSampleEntity, the setter function

      public function set title( aValue:String ):void {
      this.setKV( CSampleEntity.PROP_TITLE, aValue );
      }

      does not fire, while setKV() in CSampleEntity's super-class defined as

      protected function setKV( key:Object, value:Object ):void {
      _entityData[ key ] = value;
      _dirtyFlag = true;
      }

      and _entityData is defined in CSampleEntity's super-class like this:

      // The values of this entity
      private var _entityData:Object = undefined;

      Could someone provide insights, why this call

      var sample:CSampleEntity = new CSampleEntity();
      sample.title = 'Hello World'; // << THIS does not fire the setter

      does not fire the 'set title' setter?

      Actually, the Flex AIR debugger show an object of class CSampleEntity with a property 'title' - but the setter does not set this property!



        • 1. Re: Setter/getter does not fire
          Gregory Lafrance Level 6
          Maybe its because you are using a setter to set a class variable, not an instance variable.

          Or maybe somewhere the class loses its type and must be cast somewhere?
          • 2. Re: Setter/getter does not fire
            justria Level 1
            No, actually, _entityData is an instance variable.

            Hm, loses its type? How could this happen? An object's type can change how ?
            • 3. Re: Setter/getter does not fire
              Gregory Lafrance Level 6
              This code works. Please change it if necessary to replicate your issue:
              • 4. Re: Setter/getter do not fire
                Level 7

                "justria" <webforumsuser@macromedia.com> wrote in message
                news:gnkhoe$sk4$1@forums.macromedia.com...
                > Hi,
                >
                > in a class CSampleEntity, which gets instantaiated dynamically using
                >
                > public function createEntity( anObjClass:Class ):TAAbstractEntity {
                > var obj:TAAbstractEntity = null;
                > obj = new anObjClass();
                > return obj;
                > }
                >
                > the setter function
                >
                > public function set title( aValue:String ):void {
                > this.setKV( CSampleEntity.PROP_TITLE, aValue );
                > }
                >
                > does not fire.
                >
                > Could someone provide insights, why this call
                >
                > var sample:CSampleEntity = stm.createEntity( CSampleEntity ) as
                > CSampleEntity;
                > sample.title = 'Hello World'; // << THIS does not fire
                >
                > does not fire the 'set title' setter?
                >
                > Actually, the Flex AIR debugger show an object of class CSampleEntity with
                > a
                > property 'title' - but the setter does not set this property!

                So, if you have

                public function set title( aValue:String ):void {
                trace('aValue');
                }

                You don't see the value traced out?