1 Reply Latest reply on Feb 26, 2007 1:23 PM by RyanJNorris

    Bindable subclass

    Cédriic
      Hi,

      I'm a newbie to Flex and I have a problem with bindable classes/methods.

      I have a class A with a bindable public getter (A is bindable so are its public getters, aren't they ?), such that :

      [Bindable]
      public class A {
      private var _name:String;

      public function A() {}

      public function get name():String
      {
      return _name;
      }

      public function set name(value:String):void
      {
      _name = value;
      }
      }

      Now I want to have an inherited class from A called B.
      1) If A is bindable, is B also bindable ? I mean if I had private class variables and add some getters to deal with them, will these getters be bindable ? (In fact, i want to understand the scope of the bindable metatag)
      2) Without any answers to question 1, I tried to add some bindable getters to B, but I have a compilation problem :
      Error: Java Heap Space
      Java.lang.OutOfMemory ...

      Is there a way to make public properties of a subclass of a bindable class also bindable ? Is there a way to bypass these restrictions ?

      Thanks very much for your help !
        • 1. Bindable subclass
          RyanJNorris
          I have encountered this as well, using Flex Data Services and the [Managed] metadata (like Bindable).

          The answer appears to be that you currently cannot do this (apply [Bindable] traits to an object graph). The problem appears to be that the "magic" of object bindability isn't magical enough; if you say that both A and B (which extends A) are Bindable, then the compiler will attempt to add it's magic to both classes. The magic appears to be actual AS3 code which is hidden from the developer. What this magic doesn't do is detect overrides between the magic implemented on B that is also implemented on A. The design of the compiler appears to handle this BEYOND poorly, and thus you get the heap space issue.

          Beyond the technical implications of this, this is a serious architectural problem. The only solution is to either a) trust that the most remote cousin in your object graph is the one that will be needed by your code (then why bother) or b) throw out inheritance altogether.

          See my blog entry regarding more about this. What's even more frustrating about this is that Flex Builder seems to blissfully ignore the error. I would assume there's some compiler flag being sent to Compc or MXMLC to tell it to ignore this issue. Would somebody from Adobe be so nice as to look into this? Not being able to apply object binding to inherited objects is a real kick in the pants.