Dec 19, 2010
I have a holder movieclip, its base class is foo.[code]I put a trace in the constructor of bar so I can tell if it's being loaded properly, and when I drag out foo onto the scene and run the clip, all the little bars within it fire off correctly. However, when I add it to the scene dynamically, such as like this in the Main class:[code]Suddenly, all the little bar movieclips within foo revert to regular old movieclips and don't fire. What's interesting is if you typecast one them as Bar at some point, and their normal class is set to Bar (within the movieclip itself, rather than base class), it works and the constructors all fire, like this:[code]However, if you want multiple different types of Bar clips, and give each a base class of Bar, this won't work. They all spawn as generic movieclips. It DOES work if you go through and typecast them as either Bar1 or Bar2, but that means in practice you would have to try to typecast every child as every top-level object type every time you added the clip to the stage. You also can't have a bunch of movieclips of the same type since Flash doesn't allow it, so each one needs to be a new class, and have that class typecasted when the parent is placed on stage. Kind of defeats the purpose of OOP.
View 1 Replies
This seems to be a bug in Flash itself, but is there any way to fix it?You can download an example file here with a couple extra traces to show off what's going on: url... It still has its children, they're added and displayed, but their type changes to MovieClip, ignoring the base class.