I need to change a text field every time values in an array is updated, and I tried putting the code in the setter. However, the code is not being called. Even if I do this
public function set resources(value:*) {
//this function does not seem to matter at all
}
Nothing happens. I think AS3 overrides setters for arrays, how do I get the functionality other than inserting a changeTextFields(); every time I change the array?
I’ll address your points in reverse order:
There is no programmatic way of knowing that values inside an array have changed. As the programmer, you must perform some notifying action (e.g. raise an event or call a function) when you know that the values have changed. In you case this is calling the
changeTextFields()method whenever the values have changed..This is not directly related with
setters. i.e. there is not any special behaviour for array setters or any other type ofsettermethods.All setters do is let you treat a method as a mutable object property (that is, you invoke them with the
=operator instead of the round brackets):