[SOLVED] Override as3 getter from swc

I am trying to override protected getter only property from as3 class located in swc file (Flash target).

 @:getter(defaultStyleProvider) function getDefaultStyleProvider(): IStyleProvider {
	return CustomController.globalStyleProvider; // correct type

but get error all the time

Error #1053: Illegal override of defaultStyleProvider in …

I am doing something wrong?


Does it work if you add @:protected? Could it be the IStyleProvider portion?

No, I tried with @:protected but same result

Ok compiled test class with -as3 and looks like haxe compiler is not adding override keyword there in this case

@:getter(defaultStyleProvider) function getDefaultStyleProvider(): IStyleProvider {
	return CustomController.globalStyleProvider; // correct type

compiles to

protected function get defaultStyleProvider() : feathers.skins.IStyleProvider {
       return CustomController.globalStyleProvider;

Does it compile if you add override to your Haxe code?

No it complains that there is nothing to override.

Perhaps you need to create an extern class for the SWC types, so that you have something to override. For example:

extern class SWCClassType {
    public function hello ():Void;
class MyClassType extends SWCClassType {
    public override function hello ():Void {}

There’s also a way to replace a class defined in an SWC. For example, say you have a type in the SWC that has no code, and just defines a MovieClip symbol. You should be able to inject code using the @:bind meta-data on the SWF target, I think it works like this:

class SWCClassType extends MovieClip {
    // add your own types

Ok, wrong wording probably.

Parent as3 class in swc have defined:

protected function get defaultStyleProvider():IStyleProvider
	return null;

I have class that extends it.

if I try to override it:

@:getter(defaultStyleProvider) @:protected override function getDefaultStyleProvider(): IStyleProvider {
	return CustomController.globalStyleProvider;

compiler shows error:
Field getDefaultStyleProvider is declared 'override' but doesn't override any field

as I try to override native getter from as3 but in haxe syntax its getDefaultStyleProvider not get defaultStyleProvider

tried to make extern property but got an error that I can not redefine property from the parent.
@:extern var defaultStyleProvider(default, never): IStyleProvider;

Redefinition of variable defaultStyleProvider in subclass is not allowed. Previously declared at feathers.core.FeathersControl

will try more with externs and bind maybe will somehow push compiler to add the override to getter.

Oh, I see, overriding a Flash getter. You probably cannot name your function the same as the field, because that’s a collision.

I just found this, maybe there’s something interesting here:


this looks dead end, probably will fork lib and refactor getter to function so I can override it, not nice but I can not find any other solution here, would be nice to have untyped code in as3 :smiley:

Yeah! The tricky (and valuable, but still tricky) part is that Haxe compiles to ActionScript Bytecode directly, and avoids AS3. That’s why you can do untyped __js__ but you can’t do untyped __as3__ because Haxe skips that step for Flash

Same as here, haxe issue with protected overrides, will close this thread then.