这里是一个黑客在3.5解决此问题。
查看这个文件的来源:http://www.flexdevelopers.com/examples/validator/3.5/Tester.html
更改saveMessage()方法来读取这样的:
public function saveMessage(event:Event):void
{
setupValidators();
var failedValidations:Array = new Array();
failedValidations = Validator.validateAll(_formValidators);
if (failedValidations.length == 0)
{
Alert.show("save it");
}
else
{
for each (var validationResultEvent:ValidationResultEvent in failedValidations)
{
hackForSDK35Bug22911ToRemoveRepeatingErrorMessages(validationResultEvent);
}
}
}
再加入此方法:
private function hackForSDK35Bug22911ToRemoveRepeatingErrorMessages(failedValidation:ValidationResultEvent):void
{
var uiComponent:UIComponent = failedValidation.target.source as UIComponent;
var errorString:String = uiComponent.errorString as String;
uiComponent.errorString = errorString.split("\n")[0];
}
应删除重复错误信息,只留下一个...
好吧,看起来,一个unresol此问题存在ved错误:https://bugs.adobe.com/jira/browse/SDK-22911 – 2010-08-26 15:10:54
查看我的应用程序的源代码后,您可能想知道为什么我每次点击时创建一个新的验证器保存按钮。那么,我这样做是因为这个错误:( - https://bugs.adobe.com/jira/browse/SDK-25731 – 2010-08-26 15:13:45
你应该看看尽快迁移到Flex 4,Jeremy。 – Francisc 2010-08-26 21:15:55