這裏是一個黑客在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