fast-rain-20339
07/30/2020, 3:14 AMfast-rain-20339
07/30/2020, 3:14 AMkind-policeman-40412
07/30/2020, 3:14 AMfast-rain-20339
07/30/2020, 3:14 AMkind-policeman-40412
07/30/2020, 3:15 AMkind-policeman-40412
07/30/2020, 3:15 AMfast-rain-20339
07/30/2020, 3:16 AMREADY event handler though.kind-policeman-40412
07/30/2020, 3:17 AMfast-rain-20339
07/30/2020, 3:17 AMyourBuildComponent.joinButton though and it's null (on a static target), that means it certainly is a field. If it wasn't a field, it would crash.fast-rain-20339
07/30/2020, 3:18 AMyourBuildComponent.jsdlkfjsd)fast-rain-20339
07/30/2020, 3:18 AMkind-policeman-40412
07/30/2020, 3:18 AMkind-policeman-40412
07/30/2020, 3:19 AMkind-policeman-40412
07/30/2020, 4:16 AMComponentEvents.registerEvent method. And when I tried to use it my code does compile but in runtime I've got an Uncaught exception - Invalid call on line myBuiltComponent.registerEvent(UIEvent.READY, onReady);
Of course I've created an onReady method in the same class private function onReady(event:UIEvent):Void. What I am doing wrong?fast-rain-20339
07/30/2020, 4:18 AMfast-rain-20339
07/30/2020, 4:20 AMfast-rain-20339
07/30/2020, 4:21 AMhidden 😛kind-policeman-40412
07/30/2020, 4:28 AMHaxe
private function createUI():Void
{
ui = ComponentMacros.buildComponent("assets/ui/lobby/main.xml");
ui.registerEvent(UIEvent.READY, onReady);
container.addChild(ui);
}
private function onReady(event:UIEvent):Void
{
trace('onReady -> ui:', ui);
trace('onReady -> event:', event);
}
Where ui is a class property private var ui:Dynamic; Because only Dynamic or Box type allows me to compile this code but with Box it does not compile when I try to access joinButton. In a code above I've removed joinButton to test how event register works.kind-policeman-40412
07/30/2020, 4:29 AMfast-rain-20339
07/30/2020, 4:31 AMbuildComponent, Ian will be more help, but the type's at least make sense. Box, the Haxe UI class, doesn't have a myButton field, that's added by the macro. I wonder if you can do the create UI thing on the var line so that the type automatically gets set?fast-rain-20339
07/30/2020, 4:31 AMkind-policeman-40412
07/30/2020, 4:32 AMfast-rain-20339
07/30/2020, 4:32 AMfast-rain-20339
07/30/2020, 4:33 AMkind-policeman-40412
07/30/2020, 4:34 AMfast-rain-20339
07/30/2020, 4:34 AMfast-rain-20339
07/30/2020, 4:35 AMkind-policeman-40412
07/30/2020, 4:35 AMkind-policeman-40412
07/30/2020, 4:36 AMfast-rain-20339
07/30/2020, 4:37 AM