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

Flex3画布,滚动条

  •  0
  • OXMO456  · 技术社区  · 17 年前

    Sprite Canvas .

    var uic:UIComponent=new UIComponent;
    var s:Sprite=new Sprite(); //<-- my simple Sprite
    uic.addChild(s);
    
    myCanvas.addChild(uic);
    

    滚动条取决于 尺寸。(画布的大小是固定的)

    谢谢

    1 回复  |  直到 17 年前
        1
  •  4
  •   Josh Tynjala Ivan Chernykh    17 年前

    您发现的问题是,普通UIComponent不会向其父级报告宽度或高度值(因为它根本不知道该值应该是什么!)。

    measure() 功能。在那里,将measuredWidth和measuredHeight属性设置为UIComponent子级的大小。

    override protected function measure():void
    {
        super.measure();
    
        for(var i:int = 0; i < this.numChildren; i++)
        {
            var child:DisplayObject = this.getChildAt(i);
            this.measuredWidth = Math.max(this.measuredWidth, child.x + child.width);
            this.measuredHeight = Math.max(this.measuredHeight, child.y + child.height);
        }
    }
    

    推荐文章