4 Replies Latest reply on Mar 23, 2009 10:53 PM by bpja

    Data Binding in Flex 3 Broken?

    rwtemple
      I just upgraded to Flex 3. What a disaster:

      This used to work in Flex 2:

      private var mState:int = 0;

      [Bindable]
      public function get state():int {
      return mState;
      }

      private function set state(value:int):void {
      sLog.debug("state = {0}", ControllerState.toString(value));
      mState = value;
      }

      ...

      BindingUtils.bindSetter(onControllerStateChanged, mController, "state");

      In Flex 2, my function gets called everytime state is changed. In Flex 3, my function gets called when I call bindSetter, but never again does it get called.

      Anyone have any ideas? Do I switch back to Flex 2?

      Thanks,
      Robert Temple
      Sr. Director ESPN.com
      Developing Rich Internet Applications since 1995.
        • 1. Re: Data Binding in Flex 3 Broken?
          peterent Level 2
          Try changing your function from private to public.
          • 2. Data Binding in Flex 3 Broken?
            rwtemple Level 1
            I tried a number of things before posting here. Changing the setter to public was one of the first and that didn't help.

            • 3. Re: Data Binding in Flex 3 Broken?
              bpja Level 1
              There appears to be a bug deep in the binding machinery.

              Specifically, the code deep inside the Bindability util class relies on the typeDescription XML data from the flash runtime. However, it only expects to find the accessor and method elements immediately beneath the root element rather than nested *one level lower* in the <factory> element.

              e.g. this code

              // Get child-specific events.
              var childDesc:XMLList =
              typeDescription.accessor.(@name == childName) +
              typeDescription.method.(@name == childName);


              Should be rewritten as

              // Get child-specific events.
              var childDesc:XMLList =
              typeDescription..accessor.(@name == childName) +
              typeDescription..method.(@name == childName);


              Or does someone have a better explanation as to why some dynamic, bindable classes can't have their properties as the source for bindSetter() created bindings?
              • 4. Re: Data Binding in Flex 3 Broken?
                bpja Level 1
                There appears to be a bug deep in the binding machinery.

                Specifically, the code deep inside the Bindability util class relies on the typeDescription XML data from the flash runtime. However, it only expects to find the accessor and method elements immediately beneath the root element rather than nested *one level lower* in the <factory> element.

                e.g. this code

                // Get child-specific events.
                var childDesc:XMLList =
                typeDescription.accessor.(@name == childName) +
                typeDescription.method.(@name == childName);


                Should be rewritten as

                // Get child-specific events.
                var childDesc:XMLList =
                typeDescription..accessor.(@name == childName) +
                typeDescription..method.(@name == childName);


                Or does someone have a better explanation as to why some dynamic, bindable classes can't have their properties as the source for bindSetter() created bindings?