I extended Sprite class and I want to call additional method when
graphics.endFill() is called . As graphics is a part of Sprite , I want to override the method
get_graphics() with my extended Graphics class where to replace
endFill() with :``
but the Graphics class is
final . Why is that ?
final seriously stop extending the class functionality .
Why I can’t tell you why it was made final, nothing is stopping you from either
@:final metadata directly from Graphics.hx
make a duplicate of Graphics.hx inside your project’s source folder, which reflects the package’s location e.g. /openfl/display/Graphics.hx and remove the metadata tag there or modifiy it’s
@:hack tag to the class which should extend Graphics e.g.
@:hack class MyGraphics extends openfl.display.Graphics (though this option might cause trouble on some targets)
In Flash, the
flash.display.Graphics class is marked with the AS3
final keyword, so OpenFL also makes it final in Haxe. The
Graphics class is not meant to be extended.
You might consider using Haxe static extensions instead.
Thanks to both of you for your reply and help