【发布时间】:2011-07-15 07:45:50
【问题描述】:
我可能正在服用疯狂的药丸,但有没有人真正让 errorSkin 功能发挥作用?我没有做任何疯狂的事情,只是扩展 TextInput (spark) 并设置 errorSkin 属性。
我尝试使用 SparkSkin 创建皮肤,但什么也没做。 我曾尝试使用 ProgrammaticSkin 创建皮肤,但什么也没做。
TextInput 始终是红色边框。我知道你可以设置 errorColor 和 errorString 但我显然希望做的不仅仅是改变边框的颜色。我正在使用 Flex 4.1 进行编译。
有什么想法吗?
实施:
<components:PromptedTextInput id="txt"
width="200"
horizontalCenter="0"
verticalCenter="0"
errorSkin="skins.TestSkin" />
类
public class PromptedTextInput extends TextInput
{
public function PromptedTextInput()
{
super();
}
}
错误皮肤:
<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark">
<fx:Metadata>
<![CDATA[
[HostComponent("spark.components.TextInput")]
]]>
</fx:Metadata>
<s:states>
<s:State name="normal" />
<s:State name="disabled" />
<s:State name="error" />
</s:states>
<!-- fill -->
<s:Rect id="background"
left="1" right="1" top="1" bottom="1">
<s:fill>
<!--- Defines the background fill color. -->
<s:SolidColor id="bgFill"
color="#66CC66" />
</s:fill>
</s:Rect>
</s:SparkSkin>
另一个错误皮肤尝试:
public class TestSkin extends ProgrammaticSkin
{
public function TestSkin()
{
super();
}
override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
{
super.updateDisplayList(unscaledWidth, unscaledHeight);
graphics.clear();
graphics.beginFill(0x33CC33);
graphics.drawRect(0, 0, unscaledWidth, unscaledHeight);
graphics.endFill();
}
}
【问题讨论】:
-
如果errorSkin是替换皮肤;你不需要的不仅仅是彩色背景吗?尝试将您的 ErrorSkin 重新创建为 TextInput 外观的副本。
标签: apache-flex validation skinning textinput