3

Assume i have a costum actionscript class.

public class myClass

{
       private var myVariable:ArrayCollection;
...
}

Suppose also that i have a different class, that changes a second variable, which has the metadatatag [Bindable]. What methods and events do i have to implement in either of these classes, to make myVariable change, whenever the other is changend?

Kai
  • 376
  • 1
  • 4
  • 17

1 Answers1

1

If you make the myVariable public, then you can just use [BindingUtils.bindProperty()][1]:

public class MyClass
{
    public var myVariable:ArrayCollection;

    public function MyClass(other:OtherClass) {

        BindingUtils.bindProperty(this, "myVariable", other, "propertyName");

    }
}

If you prefer to keep myVariable private, then you can use [BindingUtils.bindSetter()][2]:

public class MyClass
{
    private var myVariable:ArrayCollection;

    public function MyClass(other:OtherClass) {

        BindingUtils.bindSetter(
            function(newVal:*):void {
                this.myVariable = newVal;
            }, other, "propertyName");

    }
}
Brian Genisio
  • 47,787
  • 16
  • 124
  • 167