2009-10-01 144 views
1

我正在使用Flex 3.4 SDK。更改标题窗口关闭按钮

我需要更改TitleWindow的默认关闭按钮图像。所以我在做什么是定义一个CSS选择器,像这样:


TitleWindow{ 
    close-button-skin: Embed('assets/close.png'); 
    border-color: #FFFFFF; 
    corner-radius: 10; 
    closeButtonDisabledSkin: ClassReference(null); 
    closeButtonDownSkin: ClassReference(null); 
    closeButtonOverSkin: ClassReference(null); 
    closeButtonUpSkin: ClassReference(null); 
} 

的问题是:结果图像完全挤压得面目全非。可能是因为图像尺寸是55x10像素(比默认的近似方形尺寸宽得多)并且弯曲使其适合该尺寸。

有人会知道如何去解决这个问题吗?

回答

3

这似乎是宽度和高度都设置为16个像素的面板类的createChildren()方法:

closeButton.explicitWidth = closeButton.explicitHeight = 16; 

你可以尝试设置explicitWidth和explicitHeight设置为你在窗口所需要的值。不要忘记将closeButton作用于mx_internal,并导入并使用该名称空间。

import mx.core.mx_internal; 

use namespace mx_internal; 

// in creationComplete for instance 
mx_internal::closeButton.explicitWidth = ...; 
mx_internal::closeButton.explicitHeight = ...; 
+0

也非常完美,非常感谢! 我选择做的是重写createChildren()并更改closeButton.explicitWidth closeButton.explicitHeight。 – camurgo

+0

谢谢!这是一个问题,我的团队中有一个以上的人遇到了麻烦!它工作得很好。 –

1

如果你想让它更简单,做到这一点,

导入类

import mx.core.mx_internal; 

把这些三线在creationComplete处理函数

use namespace mx_internal; 

closeButton.$width = 24; //Change the button width to 24 pixels 
closeButton.$height = 24; //Change the button height to 24 pixels 
+0

谢谢!我正在拼命挣扎,导致以前的答案对我来说不适用于sdk 3.5>。< –

+0

对于Flex4.5.1,代码应该简单地使用'width'和'height'。 – Chris