PDA

View Full Version : Extending Point class problem



Pjanssen
August 17th, 2008, 08:44 AM
Hi,

I'm trying to make a Vector class which will provide some basic mathematical methods. I want to have this class extend the Point class, so it can be used in functions like <DisplayObject>.globalToLocal(pt: Point)

However, when I try to make a get/set method for the x or y values, I get this error:
1023: Incompatible override.

Is there any way around this ?

senocular
August 17th, 2008, 08:47 AM
You can't override x and y of point since they are variables and not getter/setters. They're variables for performance reasons (the same applies to Matrix and I think many of the other geom classes).

Pjanssen
August 17th, 2008, 08:53 AM
Hmm that's too bad.
So I guess the option are either using different names for x and y in my vector class and updating x and y when they are set. Or writing my own globalToLocal and localToGlobal methods that accept the Vector class.
Or are there other/better options?

By the way, the main reason why I'm using get/set methods for x and y is so that I can set flags when they have changed. This is so the length and angle property are only calculated when they are used and x and/or y have been changed. And the other way around too.