Tuesday, February 2, 2010

Improved Flex Validation: Display Error Tooltip

I combined two validation concepts to arrive at my Improved Flex Validation. The key component is Joel Hooks Form Validation for the Lazy Programmer. I incorporated the UIComponent.callLater() hack for displaying error ToolTips and viola!

Full Source

Here is what the callLater() looks like:

// display errorTip
if (showErrorsImmediately &&
currentControlIsValid == false &&
supressEvents == false)
// cast the focussed control to a UIComp to use callLater
var ffc:UIComponent = focusedFormControl as UIComponent;
ffc.callLater(showDeferred, [focusedFormControl]);

return currentControlIsValid;

private function showDeferred(target:DisplayObject):void {
target.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_OUT));
target.dispatchEvent(new MouseEvent(MouseEvent.MOUSE_OVER));

No comments: