In the publish settings, you have the option (on by default) to have named child instances inside a particular MovieClip instance declared in the created class automatically.
Suppose we have a class MainController as Document Class, and a library item instanced on the root timeline with name “myClip_mc”. When automatically declaring instances, I can talk to a member property myClip_mc inside my MainController class. That may sound handy, but any self-respecting code editor with checking will start nagging that myClip_mc has not been declared. And since it hasn’t been declared, it’s untyped, therefore we don’t have code hinting. So not that handy after all.
Now let’s not declare instances automatically. Since we didn’t declare anything in the MainController class, the Flash player will try adding myClip_mc at runtime to the MainController instance, and fail with a runtime error, provided you didn’t declare MainController as a dynamic class. And you shouldn’t. So we add a public var myClip_mc:MovieClip (yes, public!) to our MainController, we get code hinting & compile time type checking, and everything compiles and runs fine. Perfect.
Well… suppose, for the sake of convience, or out of laziness, or for whatever reason, we happen to have a bunch of named instances on our timeline that we will look into later. We haven’t come to that part yet, so we haven’t bothered declaring them in the MainController class… Wrong! We’ll get a runtime error for the first undeclared named instance that can’t be added, after which the Flash player stops.
So to quote Cruijff, every upside has its downside. The good thing is of course that now at least we get a runtime error if we typed the instance name wrong in the class vs. the timeline.
No comment yet