actionscript – can i add a container to a canvas in flex using action script? – Education Career Blog

i am trying to add a container having some UI components as child in it to a canvas and also want to set the border size only using the action script without MXML,

1) is it possible to add the container that is a lower class in hierarchy from parent to child upward, can canvas addchild() accepts the container as child ?

2) how to set the border of both the canvas and the container ?

i need to do this in action script i have tried but nothing comes out here is the code: –

var contain:Container = new Container();

            if(ename.text.length >0)
            {
                var newename:TextInput = new TextInput();
                var newnamet:Label = new Label();

                newnamet.text = namet.text;
                newnamet.x = 5;

                newename.text = ename.text;
                newename.x = 100;
                newnamet.y = newename.y = 20+contain.measuredHeight;

                contain.addChild(newnamet);
                contain.addChild(newename);
                //contain.measure();

            }//end if


                    contain.x=5;
        contain.y =20+childcanvas.measuredHeight;
        childcanvas.addChild(contain);

,

Taken from the docs:

The Container class is an abstract base class for components that 
controls the layout characteristics of child components. 
You do not create an instance of Container in an application. 
Instead, you create an instance of one of Container's subclasses, 
such as Canvas or HBox.

The Container class contains the logic for scrolling, clipping, 
and dynamic instantiation. It contains methods for adding and 
removing children. It also contains the getChildAt() method, 
and the logic for drawing the background and borders of containers.

Leave a Comment