Auto-Binding Success
An update on my previous post about reflection and using it to auto-bind C++ classes to Flash objects.
The experiment was a huge success, I believe! I made an entire new UI scene with 0 actionscript, relying entirely on auto binding... The scene's C++ is less than 200 lines- all interaction + logic. For comparison, this is a reimplementation of a previous scene which was 500 lines of C++ and 300 lines of ActionScript, most of which was the communication and traversal between the two.
Of the auto-bind features, I'm using 2: Auto-Binding based on member name and treating structs as containers. The latter was especially helpful! It lets you dig 1 element deeper and keep those sub-elements organized. e.g. previously coworkers would do "PromptABtn, PromptALabel, PromptBBtn, PromptBLabel" which is a hassle. Now you can make a struct and just have "PromptA, PromptB" which both have "Btn, Label". I even added a special keyword "Self" which let's you refer to the container if needed!
There were two other main features that made it in based on coworker feedback: Custom bindings and array binding.
Some co-workers didn't like the naming enforced by UnrealScript (if you don't follow a capitalization convention it could break the entire project), so they wanted a way to bind scene elements with class members that are of different names. That's set up and works perfectly with any supported type you provide! (like structs, arrays, and scene element classes) It's implemented to work with UC's Default Properties, and I'm a fan of the syntax:
Bindings.Add((AS="sceneName", UC="ClassMember"));
And array binding is just very convenient. It matches elements in the scene that have the array variable name + a number, and populates them into the array. This lets you easily manage a bunch of generic objects / list renderers without having to do the tedious custom hookups.
Overall I'm happy with this result, so we should be able to more easily avoid AS when possible! Reflection is such a nice tool to have- it's upsetting that we don't have it natively, and won't for a few C++ iterations at this point. :x C++23 is looking to be the earliest implementation.











