What does this mean for me? You will always be able to play your favorite games on Kongregate. However, certain site features may suddenly stop working and leave you with a severely degraded experience.
What should I do? We strongly urge all our users to upgrade to modern browsers for a better experience and improved security.
We suggest you install the latest version of one of these browsers:
Kongregate is a community-driven browser games portal with an open platform for all web games.
Get your games in front of thousands of users while monetizing through ads and virtual goods.
Learn more »
I want to make a Vector2 Class which would allow me to use mathematical operators instead of having to call .add() .subtract() and so on. It’s not a life or death matter, but it’d be nice to get it to work.
So far I have discovered the Proxy Class and attempted to accomplish the task by overriding the [call property](http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/utils/Proxy.html#callProperty()) method. This has lead me to the following:
`a + b`
If both a and b are strings, concat.
If one of a or b is a string, toString() the other, concat.
If both a and b are Number/int/uint, add mathematically.
Otherwise, valueOf() each that is not a number or string, toString() each that is still not a number or string and follow the previous rules.
This poses a problem that if anything other than a number (or int/uint) is present, the operation defaults to string concatenation. And I can’t really express a Vector2 as a single number, so no matter what I do, I end up with string concatenation. While I can change the valueOf() and toString() methods, I have no way (that I know of) to control the the + operator at all.
So, is there any way to solve this problem without going completely dodgy?
I could pretty much use anything, but the functionality I want is that each set of 2 numbers is stored in 1 variable and that I am able to go var1 + var2 to return a variable of the same type for which each number is the sum of the corresponding numbers in the previous two variables. I am completely at a loss for how to do this, seemingly because it’s not possible.
`var var1 = (6,2);
var var2 = (3,4);
var var3 = var1 + var2;
trace(var3); // (9,6);`
[Point](http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/geom/Point.html).[add](http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/geom/Point.html#add()) is the closest you will get. As said earlier, AS3 does not support overloading.