Reputation: 25
I've seen a very strange thing that i know it works, but i can't seem to understand exactly why and how this works.
i have a line of code that reads this:
_game._requestedState = new (FlxU.getClass(FlxU.getClassName(_game._state,false)))();
Ok, so what i can see here, is, i'm invoking an annonymous constructor, by reflection. Is that it?
Thanks.
Upvotes: 2
Views: 57
Reputation: 5255
There's no such thing as an anonymous constructor.
The method is called FlxU.getClassName, which makes it clear that there is in fact a name involved. It takes some _game._state
, get's a class name from it and then gets the actual class from that name.
This is similar to getDefinitionByName()
, which it likely uses internally.
Upvotes: 1