问题
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