3 Replies Latest reply on Aug 11, 2011 11:26 PM by drkstr_1

    Why cannot replace the borderColor of the Tooltip?????

    Jessie_Meta

      Hi all,

       

      When I mouse over the swfLoader1, sometimes it will display the tooltip with the default borderColor(red) of "errorTipRight" border style

      but I already change the borderColor to #FFFFFF (please refer to the sample code as below).

       

      I don't why sometimes it will show the borderColor with red (default)?????

       

      Anyone can help me to solve this problem? Thanks.

       

      Sample code:

      <mx:Style>

           .errorTip

           {

               color: #1B75BB;

                fontFamily: "Century Gothic";

                fontSize: 10;

                borderColor: #FFFFFF;

                borderStyle: "errorTipRight";

                backgroundAlpha: 0.8;

           }

       

      </mx:Style>

       

       

      <mx:Script>

           import mx.controls.ToolTip;

           import mx.managers.ToolTipManager;

       

       

           private var myTip:ToolTip = null;

       

       

           private function createTip(evt:MouseEvent):void

           {

                myTip = ToolTipManager.createToolTip("Testing",evt.stageX,evt.stageY) as ToolTip;

                myTip.setStyle("styleName", "errorTip");

           }

       

       

           private function destroyTip():void

           {

                ToolTipManager.destroyToolTip(myTip);

                myTip = null;

           }

      </mx:Script>

       

       

      <mx:SWFLoader id="swfLoader1" x="110" y="9" width="25" height="32" mouseOver="createTip(event)" mouseOut="destroyTip()"/>

       

       

       

      Regards,

      Jessie

        • 1. Re: Why cannot replace the borderColor of the Tooltip?????
          Kanchan Ladwani Level 2

          Hello Jessie,

           

            Instead of calling setStyle() method,

          u can use following snippet-

          <fx:Style>
                 
                  @namespace mx "library://ns.adobe.com/flex/mx";
                  mx|ToolTip  
                  {    
                  color: #1B75BB;    
                  fontFamily: "Century Gothic"; 
                  fontSize: 10;       
                  borderColor:  #FFFFFF;     
                  borderStyle: "errorTipRight";     
                  backgroundAlpha: 0.8;       
                  }

              </fx:Style>

          U dont need to call setStyle method,this will apply styling for ur tooltips.

           

          Thanks and Regards,

          ------------------------------------------------------------------------------------------ --------

          Kanchan Ladwani | kladwani@infocepts.com | www.infocepts.com

          ------------------------------------------------------------------------------------------ --------

          • 2. Re: Why cannot replace the borderColor of the Tooltip?????
            Jessie_Meta Level 1

            Thanks Kanchan Ladwani for your help.

             

            I try the method as below, it is working for me.

             

            import mx.styles.StyleManager;

            StyleManager.getStyleDeclaration("ToolTip").setStyle("backgroundAlpha",0.8);

            StyleManager.getStyleDeclaration("ToolTip").setStyle("borderStyle","errorTipRight");

            StyleManager.getStyleDeclaration("ToolTip").setStyle("fontSize","10");

            StyleManager.getStyleDeclaration("ToolTip").setStyle("fontFamily","Century Gothic");

            StyleManager.getStyleDeclaration("ToolTip").setStyle("color","#1B75BB");

            StyleManager.getStyleDeclaration("ToolTip").setStyle("borderColor","#FFFFFF");

            • 3. Re: Why cannot replace the borderColor of the Tooltip?????
              drkstr_1 Level 4

              Not sure if this matters to you, but for anyone else that stumbles across this thread looking for a solution, that is a horribly innifient way to do it.

               

              Looking up a style decleration is a heavy operation, and there is no reason to do it for every style property you want to set. If for some reason you don't want to use CSS, I would suggest looking up the style decleration once and store the instance in a variable you can operate on. You may have to setStyleDecleration again when your finished, but I dont think so (not sure if it copies by value or by reference, but most likely reference).

               

              *edit*

               

              Strike that last statement. I just realized the fact that the above code even works indicates it copies by reference. No need to reset the style decleration once you've modofied it.