Simple monkey patch to fix ToolTipManager.toolTipClass
ToolTipManager.toolTipClass doesn't work in Flex 3.0 out of the box. While its intent of allowing you to specify a custom IToolTip implementation is great, ToolTipManagerImpl simply acts as if the property doesn't exist and instantiates an instance of ToolTip. Luckily, the fix is quite easy if you are willing to do a bit of monkey patching. You just have to make a slight modification to the createToolTip() method, making it look like the following:
errorTipBorderStyle:String = null,
context:IUIComponent = null):IToolTip
{
// ***** USE THE PROPERTY! *****
var toolTip:IToolTip = new ToolTipManager.toolTipClass();
var sm:ISystemManager = context ?
context.systemManager :
ApplicationGlobals.application.systemManager;
sm.toolTipChildren.addChild(UIComponent(toolTip));
if (errorTipBorderStyle)
{
UIComponent(toolTip).setStyle("styleName", "errorTip");
UIComponent(toolTip).setStyle("borderStyle", errorTipBorderStyle);
}
toolTip.text = text;
sizeTip(toolTip);
toolTip.move(x, y);
// Ensure that tip is on screen?
// Should x and y for error tip be tip of pointy border?
// show effect?
return toolTip;
}
Here is a diff of the base and updated classes.
As an aside, an easier fix is said to exist here, but it doesn't seem to work when calling ToolTipManager.createToolTip() directly, which is what I needed to do. If you are using toolTips normally by just setting the toolTip property I would recommend trying Peter's fix first.
I would also like to go on record that I hate the *Impl naming convention. Despite what Theo says, I like my interfaces with I's. *Impl just seems kludgy and redundant, and it reminds me of AS2.
You can leave a response, or trackback from your own site.

If I remember correctly – this ‘bug’ was marked deferred with a workaround. Workaround as in… if the bug sits long enough Ben will probably get sick of futzing with it and throwdown a monkey patch. Thanks for the bits Ben.
I have just the same problem. I wan’t to use cutom tooltip with the “createTooltip” method.
I’ve tried patching my eclipse flex with the latest 3.1SDK all afternoon and evening – but to no avail! Either the patching doesn’t work (which i think might be the most probable thing) – or the patch does not live well with 3.1?
Can you go into a BIT more detail on how you actually do the patching (ie: create a “stub” SWC to include etc.) To me, it seems that, whatever I do, it’s the original flex sdk that gets called by my app…. arrrg
regards
Morten
Hi Morten,
You don’t actually need to create a whole new SWC. To monkeypatch a class in Flex all you do is copy the class from the framework and save it in your project under the same package it came from. So in your project you would create mx.managers.ToolTipManager or whatever it is, copy in the code from the framework and then edit whatever it is you need. When your project is compiled it will use your local class instead of the one in the framework.
If thats not clear hit up Google, I am sure there is more info out there about monkeypatching Flex.
HTH,
Ben
I tried this. I created a class in mx.managers and called it ToolTipManagerImpl. I put in your code suggestion for the createToolTip function. I get this error when create…
VerifyError: Error #1030: Stack depth is unbalanced. 1 != 0.
at my.class.path::GridHeader/createToolTip()
I backed out the changes to the function (using original flex code) and tried that.
Same thing.
I seem to remember trying to do things like this before. Flex does not like it when you use its packages to overwrite its own classes.
Your error is apparently in the createToolTip() method of a class called GridHeader. Monkey patching classes in Flex definitely works and is something I’ve done multiple times. The fact you still get the error message when using the built in class, along with the error message make it certain the problem lies elsewhere.
Same shit different Day … I hate this F***** Error !
I´ve got him more than only one time in the past.
But there are very many different ways to clear it.
Is here anybody who has the ultimative answer ?^^
Greets
Q FlügeYes, this Error is a part of our life
( but things cant be changed in this time
[...] rather than the UIComponent’s tooltip property, or tooltip events. Ben Clinkinbeard’s monkey patch for ToolTipManagerImpl came in real handy for [...]