Friday, November 27, 2009

How to set a custom ToolTipManager in java flex 3.0

I needed to set a custom implementation of the ToolTipManager (more struts for our life!!!). I was looking for solution and found it. Here it is.

To register your own class you should invoke Singleton.registerClass(interfaceName, clazz) method with appropriate parameters. If class with interfaceName have been registered yet you cannot override it . It means you cannot register class in creationComplete, initialize or preinitialize handlers. You should create custom Preloader class and register class in constructor and set one to the application class via MXML code:


<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" preloader="CustomPreloader">



Here is the example of custom preloader class:

public class CustomPreloader extends DownloadProgressBar
   {
       public function CustomPreloader()
       {
           super();
           Singleton.registerClass("mx.managers::IToolTipManager2",
                                   CustomToolTipManager);
       }

   }



Maybe anyone has another solution.

No comments: