设置外观时访问hostComponent的自定义属性 - Flex 4.5,SDK 4.5

Tri*_*ist 5 properties skinning actionscript-3

使用SDK 4.1,我能够从自定义皮肤访问自定义按钮组件的自定义属性.我目前正在工作的项目需要SDK 4.5,我无法访问这些属性.这是一个例子:

自定义按钮组件

<?xml version="1.0" encoding="utf-8"?>
<s:ButtonBase xmlns:fx="http://ns.adobe.com/mxml/2009" 
          xmlns:s="library://ns.adobe.com/flex/spark" 
          xmlns:mx="library://ns.adobe.com/flex/mx"
          skinClass="components.skins.ButtonIcon_Skin"
          >
    <fx:Declarations>
        <fx:String id="iconCustom" />
    </fx:Declarations>
</s:ButtonBase>
Run Code Online (Sandbox Code Playgroud)

自定义按钮皮肤

<?xml version="1.0" encoding="utf-8"?>
<s:SparkButtonSkin xmlns:fx="http://ns.adobe.com/mxml/2009" 
             xmlns:s="library://ns.adobe.com/flex/spark" 
             xmlns:fb="http://ns.adobe.com/flashbuilder/2009"
             minWidth="21" minHeight="21" 
             alpha.disabled="0.5">
    <fx:Metadata>[HostComponent("components.ButtonIcon")]</fx:Metadata>

...

    <s:Label id="test" {hostComponent.iconCustom}" 
             horizontalCenter="0" bottom="10" />

</s:SparkButtonSkin>
Run Code Online (Sandbox Code Playgroud)

代码提示显示hostComponent.iconCustom但随后给出错误:

Access of possibly undefined property iconCustom through a reference with static type spark.components.supportClasses:ButtonBase. ButtonIcon_Skin.mxml
Run Code Online (Sandbox Code Playgroud)

RIA*_*tar 8

只需用常规皮肤替换SparkButtonSkin,你就可以了:

<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark">

    <fx:Metadata>
        [HostComponent("components.ButtonIcon")]
    </fx:Metadata>

    <s:states>
        <s:State name="disabled" />
        <s:State name="down" />
        <s:State name="over" />
        <s:State name="up" />
    </s:states>

    <s:Label text="test {hostComponent.iconCustom}" 
             horizontalCenter="0" bottom="10" />

</s:Skin>
Run Code Online (Sandbox Code Playgroud)