Access static var from child class

I have a class with inline public static vars to use for dispatching events.

This works fine from the main class, and from classes that aren’t connected to it. But when I try to access these variables from a class that extends from the main class, I get errors.


inline public static var PLAY:String = “PLAY”;

Second_Page extends Page:
dispatchEvent(new Event(PLAY)); -> error: Unknown identifier : PLAY

dispatchEvent(new Event(Page.PLAY)); -> works fine

So why can’t I access the variable from the child class?

I also get an error if I try dispatchEvent(new Event(Page.PLAY)); from the Second_Page class

Statics aren’t shared to the subclasses in haxe.
But Page.PLAY should work.
What is the error message you get?

When I do :
dispatchEvent(new Event(Page.PLAY));

I get: serverPath : String -> config : core.config.pages.Page_Cfg -> Void has no field PLAY

I have a class Page_Cfg, so I guess it tries to access that one for some reason? But that seems like a very random thing to do…

From the look of the message it seems the compiler thinks that Page is a function that takes a string, a Page_Cfg and returns Void.

You wouldn’t happen to have such function?

You are correct, I had written the constructor as “public function Page” instead of “public function new” as you are supposed to to in Haxe…

I still have a bit to go to get used to this language, thanks a lot!