Tile clone override issue

Hello everybody. This is more an Haxe Lang question than openFL. I created a child class of Tile class (lets say MyTile) and I added some properties(lets say FrameCount). Now, If I need to make a clone of an instance of the class I created I should override the clone method and 1) call the parent clone and 2) set the FrameCount prop of the new instance created. NOW the return value of the inherited clone should be of class MyTile but if I make a super.clone() call, a Tile object is returned.
I found a walkaround copying the code of the clone function of Tile Class, but is not a good practice, so if anyone can give me an elegant solution I would really appreciate.

Best regards
Luis

Try using upcast:

public override function clone():MyTile{
	var tile = cast(super.clone(), MyTile);
	tile.frameCount = 1;
	return tile;
}

Tried. Compiles ok, but when executed throws an haxe_ValueException. Cannot Cast.

There isn’t a better way to do this. You can’t force a Tile to be a MyTile instead, so you need to override clone() without calling super.clone().