Hello!
I am trying to get an array based on an object location, but looks like the array is updated only on init. When the object location is changed, the array stills with the same initial value as if it were an variable.
Thanks in advance.
Hello!
I am trying to get an array based on an object location, but looks like the array is updated only on init. When the object location is changed, the array stills with the same initial value as if it were an variable.
Thanks in advance.
That’s right. Because of the variable initialized
, the array is filled once.
override function get(from: Int): Dynamic {
if (!initialized) {
initialized = true;
for (inp in inputs) {
var val: Dynamic = inp.get();
value.push(val);
}
}
return from == 0 ? value : value.length;
}
Hm. I think it is for optimization purpose, in this case what you think is better:
For now i will just replace the nodes position and it will work. Thanks!
I don’t know how much this helps in optimization, but it’s more logical if the array is always updated. But if you need to store values (as constants), then add a check mark (as you suggested in option 1, just the opposite).
You can also assume that you can ignore the value of the initialized
variable, provided that the length of the array is 0.