开发者

Flex 4 : How to automatically resize the button based on content?

开发者 https://www.devze.com 2022-12-28 18:43 出处:网络
I 开发者_如何学运维would like to automatically resize my button (spark button) according it content (label text)? Anthony,

I 开发者_如何学运维would like to automatically resize my button (spark button) according it content (label text)?


Anthony,

This should happen by default, if you don't explicitly define a width for the control.

Z


The button is automatically resized once you addChild(...) your Button.


Ok, I found a solution :-)

public class MyButton extends Button
{
    public function MyButton()
    {           
        super();            
    }               

    override protected function measure():void
    {
        super.measure();

        this.width = this.measuredWidth;            
    }                           
}

Now, my button is always correctly resize (width).

Thanks everybody

Anthony

0

精彩评论

暂无评论...
验证码 换一张
取 消