Flex, any way to programmatically highlight a fiel

2019-08-04 08:07发布

问题:

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;"/>