I’m using openfl starling and i have an issue with haxeflag
<haxeflag name="-dce full" />.
When i use it, the application return this error:
Uncaught TypeError: Cannot read property ‘get_length’ of null
at Game.__getChildEventListeners (NewTestStarling.js:3771)
at Game.broadcastEvent (NewTestStarling.js:3707)
at Game.broadcastEventWith (NewTestStarling.js:3715)
at starling_display_Stage.addChildAt (NewTestStarling.js:3529)
at starling_core_Starling.initializeRoot (NewTestStarling.js:33342)
at starling_core_Starling.initialize (NewTestStarling.js:33317)
at f (NewTestStarling.js:36684)
at haxe_Timer.t.run (NewTestStarling.js:4740)
can you help me pls?
DCE (dead code elimination) tries to remove any variables and functions that aren’t used. However, it can’t do this perfectly, especially if you use
Dynamic variables or reflection or anything.
So what happened is, something got removed, and now it’s null, and because it’s null, you can’t get the length. To figure out what got removed, open up
NewTestStarling.js, scroll down to line 3771, and see what’s going on there. Compare this with the
Game.__getChildEventListeners function in your Haxe code, and figure out which variable caused the problem.
Once you find the variable (my guess is it’s an
Vector), go to the declaration and add “
@:keep.” (Put this either at the start of the line, or on the line before; it doesn’t matter.)
You can also add “
@:keep” in front of “
class Game” to make it keep everything in the
Game class. Assuming you’re using everything in the class, this won’t be a problem.