(flex mobile)如何在我的自定义布局中添加元素

时间:2012-05-06 09:48:59

标签: flex layout mobile

这是我的代码:

public class my_Layout extends LayoutBase
{
    public function my_Layout(){
        super();
        var b:Button = new Button;
        b.label="my button"
        addChild(b)
    }
}

但它显示错误,我的方法addChild未定义,

所以我可以做,谢谢

1 个答案:

答案 0 :(得分:0)

private function get_list():List{
        var list:List = target.parent.parent.parent.parent as List;
        return list;
    }
    private function get_document():View{
        var list:List = get_list();
        return list.document as View;
    }

var list:List = get_list();
        var document:View = get_document();
        var b:Button = new Button;
        b.label = 'wwwwwwwwwwwwwwwwwwwwww';
        document.addElement(b);
相关问题