How To Use The Flex Tooltipmanager To Create Error Tooltips
two methods that let you programmatically use ToolTips. These methods are createToolTip() and destroyToolTip(), which you use to create and destroy new ToolTip objects. When you create a ToolTip object, you can customize it as you would any object, with access to its properties, styles, events, and effects. The createToolTip() method has the following signature: createToolTip(text:String, x:Number, y:Number, errorTipBorderStyle:String, context:IUIComponent):IToolTip The text parameter defines the contents of the ToolTip. The x and y parameters define the x and y coordinates of the ToolTip, relative to the application container. The errorTipBorderStyle parameter sets the location of the pointer on the error tip. This parameter is optional. If you specify the value of the errorTipBorderStyle parameter in the createToolTip() method, Flex styles the ToolTip as an error tip. Valid values are "errorTipRight", "errorTipAbove", or "errorTipBelow", and indicate the location of the error tip relative to the component. If you set the errorTipBorderStyle parameter to null, then the ToolTip is a normal ToolTip, not an error tip. The following example shows the valid values and their resulting locations on the error tip: The context parameter determines which StyleManager is used. Typically, you pass the object on which the ToolTip appears, so that the ToolTip's StyleManager is the same one use by that object. This object must be of type IUIComponent, so you might need to cast it in some cases, such as when you want to specify the context as the event.currentTarget in an event handler. For more information about using error tips, see Using error tips. The createToolTip() method returns a new ToolTip object that implements the IToolTip interface. You typically cast the return value of this method to a ToolTip, although it is more efficient if you do not do this. To cast, you can do one of the following: Use the as keyword, as the following example shows: myTip = ToolTipManager.createToolTip(s,10
xmlns:mx="http://www.adobe.com/2006/mxml">
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us http://stackoverflow.com/questions/5226206/flex-4-desktop-app-tooltipmanager Learn more about Stack Overflow the company Business Learn more about hiring developers or http://stackoverflow.com/questions/9265724/custom-tooltips-using-tooltipmanager-createtooltip posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Flex 4 Desktop App TooltipManager up vote 0 down how to vote favorite I have a flex app that used to be an internet based app. In it I have a function that creates tooltip error messages when I tell it to create an error message. I pulled this app out verbatim to a desktop app and restructured things a bit to get it to run, but I did not mess with the core fundamentals of the mxml how to use file that utilizes this aside from changing the root tag from a type of 's:Group' to 's:Window' Everything runs correctly, but the tooltips are not displaying. I can't seem to figure out why, so I thought I'd run this by you guys. Here's the tooltip code (inline mxml code in the fx:script cdata tag): import mx.controls.ToolTip; import mx.managers.ToolTipManager; public var errorTip:ToolTip; private function createErrorMsg(errorMsg:String, object:Object):void { if (errorTip){ToolTipManager.destroyToolTip(errorTip);}; errorTip = ToolTipManager.createToolTip(errorMsg,object.getBounds(root).x + object.width,object.getBounds(root).y) as ToolTip; errorTip.setStyle("styleName", "errorTip"); errorTip.visible = true; errorTip.enabled = true; } Basically, I pass the function a string and an object (text input, checkbox, button, etc...etc...) and it positions it and displays the error message. This fully works in my web version, but not in my desktop version. Here's the code that instantiates the window: var window:LoginWindow = new LoginWindow(); Window.systemChrome = NativeWindowSystemChrome.NONE; Window.transparent = true; Window.open(true); Window.maximize() Any ideas? On a side note, I check to see if the errorTip exists at the beginning of the function and then destroy it so that the higher scoped variable 'errorTip' always equals the reference to the currently displayed error. This allows me to just destroy that error tip on form validation and then error check again, but it
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site