2 Replies Latest reply on Jul 1, 2006 6:09 PM by SuperConfused

    Need some help with roll over buttons

    SuperConfused
      I've imported a map from Illustrator and I want regions of it to light up when rolled over. I spread the sections of the map to various layers, converted each one to a button and now I've added this code to each one:

      on (rollOver, rollOut) {
      sangabriel.onRollOver = function() {
      this._alpha = 75;
      };
      sangabriel.onRollOut = function() {
      this._alpha = 100;
      };
      }
      on (release) {
      getURL("");
      }

      Since the stage is white, the map sections "light up" on rollover. The url's haven't been added yet.

      Anyway, it works except for one thing. When the mouse enters a map section the first time I get no reaction. However on entering a section (11 in all) a second time, it behaves properly and "lights up." After that they all work perfectly. But why do I have to roll over these twice before they work each time I test the graphic?

      Do I need to set some varables? Enable something?
        • 1. Re: Need some help with roll over buttons
          blemmo Level 1
          You mixed up two ways of assigning events here: way 1 is adding
          on(rollOver){ ... }
          to a movieclip or button instance, way 2 is using
          instancename.onRollOver = function(){ ... }
          in the timeline. Way 2 is the dynamic way of assigning events, so you use the on(xxx) event to assign the onRollOver event dynamically. That's why it only works in the 2nd rollOver: in the 1st, the events get assigned, in the 2nd, they execute.

          So you should decide which way to use, either this in the button's actions:

          on (rollOver) {
          this._alpha = 75;
          }
          on(rollOut) {
          this._alpha = 100;
          }
          on(release) {
          getURL("");
          }

          or this in a timeline frame:

          sangabriel.onRollOver = function() {
          this._alpha = 75;
          };
          sangabriel.onRollOut = function() {
          this._alpha = 100;
          };
          sangabriel.onRelease = function() {
          getURL("");
          };

          cheers,
          blemmo
          • 2. Re: Need some help with roll over buttons
            SuperConfused Level 1
            Thanks very much, that was it. Everything is working smoothly now.