Flex, any way to programmatically highlight a field in red the way the validators do?

守給你的承諾、 提交于 2019-12-24 12:33:56

问题


I'm doing some programmatic validation of some field values in a form, is there any way in Actionscript to highlight the field in red the way the validators do?


回答1:


you just need to set errorString property on programmatic validation error

<s:TextInput errorString="error string value" />
<mx:TextInput errorString="error string value" />



回答2:


Using:

var textField:TextField = new TextField();
addChild(textField);

To highlight the background in AS3:

textField.background = true;
textField.backgroundColor = 0xFFF000;

To highlight the border in AS3:

textField.border = true;
textField.borderColor = 0xFFF000;

To turn it off, just set the appropriate boolean to false.




回答3:


Try using glow filter:

<fx:Declarations>
    <s:GlowFilter id="gf" color="#ff0000" alpha="1" blurX="5" blurY="5" />
</fx:Declarations>

<s:TextInput id="ti" width="80%"/>
<s:ToggleButton id="btn" label="glow on/off" click="ti.filters = btn.selected?new Array(gf) : null;"/>


来源:https://stackoverflow.com/questions/10272041/flex-any-way-to-programmatically-highlight-a-field-in-red-the-way-the-validator

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!