Posted on Sunday 29 May 2005
Yet another oddity that is completely beyond my comprehension: getters/setters for components properties via Inspectable can be called BEFORE the instance is created and the constructor is called. What that means is that if you’re expecting, like I was, that the instance is properly initialized in those component getters/setters, well, you’re wrong, they’re not, and it can bring about subtle, incomprehensible bugs that are near impossible to debug. For example, in my init function I was setting my movieclip’s alpha to 0, and one of the component properties was calling a refresh function that was checking the movieclip’s alpha, and if it wasn’t 0, then fadeout… so the movieclip was flashing at the very beginning without any good reason.
Which reminds why I stay far far away from using MovieClip inheritance as much as possible: it is inherently evil. Composition (making a class, and letting that class keep references to movieclips without being a movieclip itself) is orders of magnitude more reliable and efficient. I’ve seen people (some who read my blog in fact) proto the root timeline to a class. That IMHO is a very nasty, bad, awful idea. I think the line between the graphics and the logic is much less blurred with a simple var ctrl:Controller = new Controller(this) on the first frame of the main timeline. But I am very sure others will disagree ;)


