gpt4 book ai didi

actionscript-3 - 在换肤时访问 hostComponent 的自定义属性 - Flex 4.5、SDK 4.5

转载 作者:行者123 更新时间:2023-12-04 06:43:37 25 4
gpt4 key购买 nike

使用 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>

自定义按钮皮肤
<?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>

代码提示显示 hostComponent.iconCustom但随后给出了错误:
Access of possibly undefined property iconCustom through a reference with static type spark.components.supportClasses:ButtonBase. ButtonIcon_Skin.mxml

最佳答案

只需将 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>

关于actionscript-3 - 在换肤时访问 hostComponent 的自定义属性 - Flex 4.5、SDK 4.5,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6268281/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com