代码之家  ›  专栏  ›  技术社区  ›  Badr

我可以使用操作脚本在flex中向画布添加容器吗?

  •  0
  • Badr  · 技术社区  · 15 年前

    我正在尝试将一个容器添加到画布中,其中包含一些作为子级的UI组件,还希望仅使用不带MXML的操作脚本设置边框大小,

    1)Canvas AddChild()是否可以从父级到子级添加层次结构中较低级别的容器,Canvas AddChild()是否可以接受该容器作为子级?

    2)如何设置画布和容器的边框?

    我需要在我尝试过的操作脚本中执行此操作,但这里没有显示任何代码:

    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);
    
    1 回复  |  直到 15 年前
        1
  •  3
  •   PatrickS    15 年前

    取自文件:

    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.
    
    推荐文章