can you create subclasses of Object2D, and/or any of its subclasses?
Yes you can, as a matter of fact that is an major internal function of my gPDF class
can you create an array of those subclasses?
Yes you can. but the array would have to be either Variant or explicitly “myObject2d”… if the array is Object2D then you won’t have access to any properties you added.
I would leave the array as type Object2D and cast the elements as myObject2d when you need to access the extra properties. That would give you the greatest flexibility.
Object2D is the base class for PixMapShape
if myObject2D is a subclass of Object2D then where Object2D could be described as the Parent of PixMapShape, then myObject2D would be an Uncle
So changes added to myObject2D won’t affect anything inheriting from Object2D
Perhaps EXTENDS might help, depending again, on just what you are attempting to do
I want to create an array of MyObject2D() that can hold objects of any of the Xojo Object2D subclasses (FigureShape, OvalShape, PixmapShape, and so on). So far this doesn’t seem possible. I either get a compile error telling me the types are mismatched, or I get an illegal cast runtime exception.
dim p as new PixMapShape
dim m as myObject2D = p // throws a Type Mismatch compile error
dim p as new PixMapShape
dim m as myObject2D = myObject2D(p) // throws an IllegalCastException at runtime
So you want your changes to Object2D to propagate to all the other classes - pixmapshape, figureshape, etc.? That doesn’t work. It would be better in that case to create a “wrapper” class that has as one of it’s properties an Object2D, along with the additional properties you want to add to Object2D. Then you can assign a pixmapshape to that object2d property.