When compiling a project that uses robotleges in the Flash IDE, it always throws a null error at runtime (cannot access a null object…). Previously I had only ever compiled in FDT and never had this problem; puzzled, I compiled the DocumentClass with FDT, and surprisingly there was no problem at all. It only errors at runtime when compiled in the Flash IDE. I figured the cause might be a failed injection, because all the variables that errored were Inject variables.
Ultimately, the cause was that the Flash compiler ignored the [Inject] metadata.
Solution Method 1: Just check “Publish SWC” in the publish settings, and it will force the Flash compiler to make all metadata take effect. Method 2: Add the compiler arguments -keep-as3-metadata+=Inject -keep-as3-metadata+=PostConstruct. The reason this error doesn’t occur when compiling with FDT normally is that the robotlegs swc has already added the arguments.
I prefer Method 1.