0

アイコン画像に応じてボタンの幅のサイズを変更したいと思います。パディングを強制的に 0 にしようとしましたが、成功しませんでした。

タイルで

<mx:Button id="m1"  icon="@Embed('m1.png')"/>

結果を見る

http://img513.imageshack.us/my.php?image=iconkg3.png

このギャップをどのように変更できますか?

アイコン http://img513.imageshack.us/my.php?image=iconkg3.png

ありがとう。

4

1 に答える 1

3

creationComplete イベントにリスナーを追加すると、次のコードを使用できます。

    private function OnCreationComplete(event: Event): void
    {
        if (event.target is Button)
        {
            var button: Button = (event.target as Button);
            var icon: DisplayObject = button.getChildByName("upIcon");
            if (icon) // check icon existence
            {
                button.width = icon.width;
                button.height = icon.height;
            }
        }
    }

動作するはず...

于 2008-12-04T13:13:18.407 に答える