【发布时间】:2014-06-17 10:07:28
【问题描述】:
对于 Flex 4.6 按钮,可以定义标签和图标:
<s:Button icon="{@Embed('assets/icon.png'}" label="Do the dance" />
对应的皮肤部分是:iconDisplay:BitmapImage和labelDisplay:IDisplayText,由组件(adobe ref)设置。它们在 ButtonBase.as 中定义
spark.components.supportClasses.ButtonBase
//--------------------------------------------------------------------------
//
// Skin parts
//
//--------------------------------------------------------------------------
[SkinPart(required="false")]
/**
* A skin part that defines an optional icon for the button.
*
* @langversion 3.0
* @playerversion Flash 10.1
* @playerversion AIR 2.0
* @productversion Flex 4.5
*/
public var iconDisplay:BitmapImage;
[SkinPart(required="false")]
/**
* A skin part that defines the label of the button.
*
* @langversion 3.0
* @playerversion Flash 10
* @playerversion AIR 1.5
* @productversion Flex 4
*/
public var labelDisplay:IDisplayText;
spark.components.Button 扩展了 ButtonBase 并添加了一些新样式和 _emphasized 属性,但没有提及有关 iconDisplay 的任何内容。所以在我看来,用于实际绘制按钮的唯一类是皮肤类。如果我们去 spark.skins.spark.ButtonSkin 这是 Flex 使用的默认皮肤(或者是它?),我们会发现:
<!-- layer 8: text -->
<!--- @copy spark.components.supportClasses.ButtonBase#labelDisplay -->
<s:Label id="labelDisplay"
textAlign="center"
maxDisplayedLines="1"
horizontalCenter="0" verticalCenter="1" verticalAlign="middle"
left="10" right="10" top="2" bottom="2">
</s:Label>
这样可以显示一个标签,但是皮肤没有<s:BitmapImage id="iconDisplay">所以我不明白为什么没有容器显示图标时显示它?
【问题讨论】:
标签: actionscript-3 apache-flex flex-spark skins