5 Replies Latest reply on Jun 25, 2008 4:14 PM by clbeech

    Controlling text button rollovers with AS?

    dawells
      I've been trying to figure this out for a few days - but still no luck. I'm trying to be able to control the state of a text button via script. For example, when someone is on a particular page, I want the button to show as red text (the "down" state) with the others still in their normal state. I haven't figured out any way to do this at this point.

      Anyone?
        • 1. Re: Controlling text button rollovers with AS?
          clbeech Level 3
          well if you are using a 'button' symbol - you won't be able to 'stop' at a particular state - that one of the disadvantages of the simple button class. the best thing to do is to make a MovieClip symbol button - which will do the same thing, but you can tell the MC to gotoAndStop at the '_down' state. under AS2 - if you label three states within a MC symbol with: _up, _over, and _down - and the add a handler like onPress to the mc - Flash will 'recognize' it as being used as a button and will automatically use the other appropriate handlers (eg. onRollOver, etc) without having to program them. so using this method, you can then call to the button that works for that 'page' and tell it to disable, and stop on the '_down' state. you will also need a method to iterate through any other buttons that were previously place in the down state and disabled - to re-enable them and place them in the _up state.
          • 2. Re: Controlling text button rollovers with AS?
            dawells Level 1
            Thanks much - that seems to be exactly what I'm thinking. Is there any place where you could point me to some sample code that does this? I get the concept, but am having a hard time translating it to actual code.
            • 3. Re: Controlling text button rollovers with AS?
              velocity-vector
              // very teeny-tiny example

              play_mc.enabled = true;

              play_mc.onRollOver = function () {
              something_mc._alpha = 50;
              }

              play_mc.onRollOut = function () {
              something_mc._alpha = 100;
              }

              play_mc.onRelease = function () {
              gotoAndPlay (2);
              play_mc.enabled = false;
              something_mc._alpha = 50;
              }
              • 4. Re: Controlling text button rollovers with AS?
                dawells Level 1
                Thanks so much - that was very helpful.
                • 5. Re: Controlling text button rollovers with AS?
                  clbeech Level 3
                  that's right velocity - however my point was that in utilizing the mc labels - you do not need to write the other on handlers for each mc button instance - here is a example of the structure of a mc button of this type - although this file was meant for something else, you can see that the only handler assigned is the onPress: HERE - additionally one still does need to 're-enable' the other buttons when a different one is activated. by placing the instance names of all of your buttons within an array you can iterate through them and set both the handler and then the 'states' when called, something like this: