How do i addChild from within an .AS class?
i have a class that contains multiple Shapes... i want to apply addChild to all of these at once from within the class... something like:
public class MultiShape
{
private var shapes:Vector.<Shape> = new Vector.<Shape>(3) ;
public function MultiShape()
{
var i:int ;
for ( i = 0 ; i < 3 ; i++)
{
shapes = new Shape() ;
// setup shapes appaearance
addChild( shapes) ; // *** doesn't work ***
}
}
}
i create instances of the class in the timeline code... there i can use 'addChild' by itself to add disply objects to the stage, as if the stage is 'this'... i would like to use/refer the stage in the class to be able to use 'addChild' to add the graphic Shape elements to the stage... but this i don't think is allowed...
a possible work around i considered was to create a Shape in the timeline, add it to the stage, wait for it to be added, and pass this Shape to the class so it could use that Shape's 'stage' property... but that seems a bit convoluted...
i should point out my class does not extend anything... it is meant to be a collection of graphic elements treated as one object...