This problem has a technical name, I can never remember if this is co- or contra-variance. There's no pretty solution in a strongly-typed language (as you surely know from writing Java).

I think your best bet is to declare a textsprite slot and use that to access the textsprite interface when needed (that way you only have one cast to make -- at construct time).

On 2008-01-07, at 18:41 EST, Henry Minsky wrote:

In LzView, the "sprite" instance var is pointing to an instance of
LzSprite, whereas in LzText, it expects to talk to
an instance of LzTextSprite (which is a subclass of LzSprite).

LzText calls a number of LzTextSprite methods, such as in it's construct method:

   this.sprite.__initTextProperties(args);

So in as3, you're not allowed to override a superclass's instance var
with a var of the same name but a different type.

This is a particular issue because I am not declaring LzSprite
dynamic, I want it to be a sealed class
in order to get the performance benefits.


So how should this be handled?

Should I cast it before each call, or declare another var with type
LzTextSprite and point the sprite var at it?




--
Henry Minsky
Software Architect
[EMAIL PROTECTED]

Reply via email to