CAAT.ActorContainer

A CAAT.ActorContainer instance, is a holder for other Actors including other CAAT.ActorContainers instances. Its main responsibility is to contain and manage other Actors.

That means, it will compound every operation hierarchically for itslef and its contained Actors so that it will compose its transformations to all of its contained Actors, and that it will animate, paint and destroy its children when necessary.

The most special kind of ActorContainer are the Director themselves, as well as every Scene instance. That means, you can set a transformation on the Scene and it will be applied for every contained actor, as in the scene switching performed by the Director.

All the particularities of the CAAT.Actor object instances, apply and are available as well in every kind of ActorContainer.

While treating with ActorContainers, we'll take special attention on Alpha composition. If isGlobalAlpha flag is set, the ActorContainers Alpha value will be set as the reference for all of its children. Otherwise, the alpha value will be set only for this ActorContainer and won't affect any contained children.


                var _director_9= new CAAT.Director().initialize(
                        400,
                        200,
                        document.getElementById('_c9'));

                // create a vertical gradient to apply to text.
                var gradient= _director_9.ctx.createLinearGradient(0,0,0,_director_9.canvas.height);
                gradient.addColorStop(0,'#ffff00');
                gradient.addColorStop(0.5,'#00ffff');
                gradient.addColorStop(1,'blue');

                var _scene_9= _director_9.createScene().
                        setFillStyle(gradient);

                _director_9.addScene( _scene_9 );

            // Global alpha false (default)
                var _c9_c0= new CAAT.ActorContainer().
                        setBounds( 10,10, 180,180 ).
                        setFillStyle( 'red' ).
                        setAlpha(.25);

                var _c9_child0= new CAAT.ShapeActor().
                        setShape( CAAT.ShapeActor.prototype.SHAPE_CIRCLE ).
                        setFillStyle( 'green' ).
                        setBounds( 20, 20, 140, 140 );

                _c9_c0.addChild( _c9_child0 );

            // Global alpha true
                var _c9_c1= new CAAT.ActorContainer().
                        setBounds( 210,10, 180,180 ).
                        setFillStyle( 'red' ).
                        setAlpha(.25).
                        setGlobalAlpha(true);

                var _c9_child1= new CAAT.ShapeActor().
                        setShape( CAAT.ShapeActor.prototype.SHAPE_CIRCLE ).
                        setFillStyle( 'green' ).
                        setBounds( 20, 20, 140, 140 );

                _c9_c1.addChild( _c9_child1 );

                _scene_9.addChild( _c9_c0 );
                _scene_9.addChild( _c9_c1 );

                CAAT.loop(1);