2 Replies Latest reply on Aug 14, 2006 2:31 PM by RSHerhuth

    Setting a buttons aplha in actionscript

    RSHerhuth
      I have a situation where I have 5 buttons on stage. I want to change 4 buttons Alpha properties to 50% when I mouseover one of the buttons. I had success in changing the alpha of everything when I use:

      on (rollOver)
      {
      _root._alpha=50;
      }

      on (rollOut)
      {
      _root._alpha=100;
      }

      But I can't seem to get it to work on just a target button.

      Also where do I find the instance name to refer to in code?

      Thanks,
      Ron
        • 1. Re: Setting a buttons aplha in actionscript
          Josh_Pratt Level 1
          the code '_root.alpha = 50; changes every single thing on the _root to be alpha of 50.

          Find where your buttons are (make sure you've given them instance names) and then change the alpha for just the buttons.

          If all your buttons are on the main timeline stage, on each button you could put something like:

          on (rollOver) {
          _root.buttoninstance._alpha = 50;
          _root.nextbuttoninstance._alpha = 50;
          etc. for each button.

          And do the same for the rollout.


          Otherwise, on your main timeline, you could put all your code for all the buttons on the first keyframe of your actions layer. I find it easiest to manage this way. Here's how it might look like:

          Let's say you've got 5 buttons. Their names are btn1, btn2, etc.

          btn1.onRollOver = function() {
          btn1._alpha = 50;
          btn2._alpha = 50;
          btn3._alpha = 50;
          btn4._alpha = 50;
          btn5._alpha = 50;
          }

          btn1.onRollOut = function() {
          btn1._alpha = 100;
          btn2._alpha = 100;
          btn3._alpha = 100;
          btn4._alpha = 100;
          btn5._alpha = 100;
          }

          To find instance names, in your actions window, click on the little crosshairs target thing icon.