Announcement

Collapse
No announcement yet.

Best way to use button rollover/out?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Best way to use button rollover/out?

    I want to have a label update it's text when the cursor is over a button.. kind of like a tool tip. I have it working just fine, but am wondering if there is a more efficient way to do it. Here is what I'm using now:

    Code:
    var SPtip:String = "Rehearse in single player mode";
    
    BtnSP.addEventListener("rollOver", this, "UpdateSPTooltipOver");
    BtnSP.addEventListener("rollOut", this, "UpdateSPTooltipOut");
    BtnSP.focused = false;
    
    function UpdateSPTooltipOver() {
    	
    	lblTooltip.text = SPtip;   
    }
    
    function UpdateSPTooltipOut() {
    	
    	lblTooltip.text = "";   
    }
    I'm just setting up vars with the needed strings then using them based on what button is rolled over. But it seems a bit inefficient to have rollover and rollout functions for every button doesn't it?

    #2
    That's fine, but if you want to share the same rollOver and rollOut functions for all of the buttons, write your functions like so:

    Code:
    function UpdateTooltipOver(event:Object) {
        switch(event.target) {
            case(BtnSP):
    	    lblTooltip.text = SPtip;
                break;
        }
    }

    Comment


      #3
      Just what I was after... thanks!

      Comment

      Working...
      X