[SOLVED] Flash: Error #1065: Variable initialize is not defined

Hi,
have someone saw such type of error? Tried to find the usual causes of it but there were not many cases described. I get it by overriding protected methods from flash SWC file (featherUI).

class TabPageBase extends ScrollScreen {
    public function new() {
        super();
    }
    @:protected
    override function scrollContainer_addedToStageHandler(event: Event) {
        super.scrollContainer_addedToStageHandler(event);
        width = cast(owner, ScreenNavigator).width;
        height = cast(owner, ScreenNavigator).height;
        addContent();
        create();
    }
    @:protected
    override function initialize() {
        super.initialize();
        verticalScrollPolicy = ScrollPolicy.ON;
        horizontalScrollPolicy = ScrollPolicy.OFF;
        scrollBarDisplayMode = ScrollBarDisplayMode.FLOAT;
        hasElasticEdges = true;
        snapToPages = false;
    }
}

This will cause error 1065 at runtime (compiles just fine). If I comment out 1 of method than other is givving same error. But if super.initialize();is commented out than error dissapears. It looks to me as some collision issue but I can not pinpoint cause of it :smiley:

Thank you

How are you defining ScrollScreen?

@singmajesty it comes from featherui swc. looks quite normal class. validate method is a bit deeper in the inheritance chain. I start to think that haxe 4 preview what I use, have issues with an override of protected methods in as3 from the swc, its second issue for me.

Do you define any Haxe externs for the class? Is it marked as @:protected there?

No just add swc to project

Hmm, so maybe it’s something with the SWC logic, that isn’t properly preserving protected (which isn’t a problem unless you try to override).

Please read this about SWC patch files:

http://old.haxe.org/manual/swc#patch-files

Perhaps it’s possible to write a small patch file, and mark the field as @:protected so it can be overridden properly?

Created patch file and included in project.xml, same result,

@:protected feathers.core.FeathersControl.initialize
@:protected feathers.controls.ScrollScreen.scrollContainer_addedToStageHandler
<haxeflag name="--macro patchTypes('lib/starling.patch')" />
<haxeflag name="-swf-lib" value="lib/starling.swc" />
<haxeflag name="--macro patchTypes('lib/feathers.patch')" />
<haxeflag name="-swf-lib" value="lib/feathers.swc" />

checked swc in vscode and got such signeture:

protected native function initialize():void;
protected native function scrollContainer_addedToStageHandler(event:starling.events.Event):void;

ScrollContainer and other classes in the hierarchy also override initialize, but it seems strange that at runtime, it’s triggering that there is no initialize method at all to override.

Perhaps when you call a super method, it needs a direct reference to which class the method is coming from. Since ScrollScreen itself lacks an initialize method, perhaps that is why this is occurring.

I found this bug:

Perhaps a solution instead would be to try and patch the type in the SWC to be public instead of protected?

tried this but same error:

@:public feathers.core.FeathersControl.initialize
@:public feathers.controls.ScrollScreen.scrollContainer_addedToStageHandler

but I found something weird, I changed my code to override public function initialize ... and the compiler didn’t complained that there is no public method at compile time :open_mouth:

This returns null

trace(this.initialize);

Yes, looks like making method public helps, but it means 170 manually renamed files in feather framework as local fork :smiley:
And as the issue you attached is closed it will stay like this, with broken protected override in flash target.

Ok, will push me to faster leave feather/starling in flash and, move to openfl / haxeui. :smiley: