First, you have a misconception, that when you create a CallItems
(note in ActionScript Class names should be in Camel Case with an initial capital leter), that somehow the Classes that CallItems
uses will not be compiled into the Class that creates the CallItems
instance. Everything that every Class that is directly referenced by your Class uses gets compiled in.
To resolve that, you need to program to Interfaces, and have your Document Class only know about the Interface. There are two ways I know of to populate variables of an Interface type without having the Document Class have a reference to the implementation.
- Put the items on stage in the IDE, and give them instance names to match the variables you used, and assign a Base Class that implements the Interface. Note that the Class will still be compiled into the swf, because it's used in the swf, but your actionscript code will not have direct knowledge of it.
- Load in an external swf. The implementation will be compiled into the other swf.
Now, to your actual problem. Your CallItems
instance is adding to the stage, rather than to itself. Since it has not yet been added to the stage (and I'd recommend that your Engine
add it to itself if you're going to go through the tiresome and tedious process of creating and adding everything through code) rather than adding to the stage.
Display Objects do not have a reference to the stage until they have been added to something that is on the display list.
You may also want to consider why you're adding calling
in Engine
, since you presumably think that calling
is already adding the things it makes to the stage (except it doesn't have a reference to the stage).