Skip to content

Instantly share code, notes, and snippets.

@joshtynjala
Created March 3, 2011 19:08
Show Gist options
  • Save joshtynjala/853311 to your computer and use it in GitHub Desktop.
Save joshtynjala/853311 to your computer and use it in GitHub Desktop.
Normally, a tool tip appears on roll over when the errorString property is set. This app demonstrates how to hide the error tip. Thankfully, Flex 4.5 adds the showErrorTip style, but this offers a workaround for older versions.
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx">
<s:layout>
<s:VerticalLayout horizontalAlign="center" verticalAlign="middle"/>
</s:layout>
<s:RichText width="300">
<s:p>Normally, a tool tip appears on roll over when the errorString property is set. This app demonstrates how to hide the error tip. Thankfully, Flex 4.5 adds the showErrorTip style, but this offers a workaround for older versions.</s:p>
</s:RichText>
<s:TextInput id="textInput" initialize="textInput_initializeHandler(event)"
errorString="OMG! THE SKY IS F#$*ING FALLING!"/>
<fx:Script>
<![CDATA[
import mx.core.mx_internal;
import mx.events.FlexEvent;
import mx.managers.ToolTipManager;
private function removeErrorTip():void
{
//lie to the tooltip manager about the error string!
//sucker.
ToolTipManager.mx_internal::registerErrorString(textInput, textInput.errorString, "");
}
protected function textInput_initializeHandler(event:FlexEvent):void
{
this.removeErrorTip();
//we're going to hook into the event dispatched for binding.
//if the error tip changes, we can remove it again.
textInput.addEventListener("errorStringChanged", textInput_errorStringChanged);
}
protected function textInput_errorStringChanged(event:Event):void
{
this.removeErrorTip();
}
]]>
</fx:Script>
</s:Application>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment