Does anyone know if it’s possible to add objects as a whole together using operators rather than breaking them apart or using object.method() format? Below is a simple example of what I would like.
Want to do:
var obj1 = new MyClass(1,2);
var obj2 = new MyClass(3,4);
obj1 += obj2;
obj2 = obj1 * 5;
trace(obj1); // 4,6
trace(obj2); // 20,30
Don’t want to do:
var obj1 = new MyClass(1,2);
var obj2 = new MyClass(3,4);
obj1 = obj1.add(obj2);
obj2.num1 = obj1.num1 * 5;
obj2.num2 = obj1.num2 * 5;