Play on mouseover, fade out on mouseout?

Hi, I want to create a flash movie that will start playing an animation with music when you mouseoveer, then fade it out when the mouse leaves. I want to have three of them on the same page (please see current site here)

How would I go about doing this? Would i put a movie inside a button in the “over” attribute, but how would i fade out the music when the user mouses over to another of the three animations?

Help much appreciated!

You can set the onMouseOver event of the MovieClip you want to target to get it to start playing.

your_clip.onMouseOver = function() {
   this.gotoAndPlay(2);
}

And then, on the onMouseOut event you can fade the MovieClip out.

your_clip.onMouseOut = function() {
   this.onEnterFrame = function() {
      this._alpha = this._alpha - 1;
      if (this._alpha == 0) {
         delete this.onEnterFrame;
      }
   }
}

I haven’t tested this, but it should get you started on what you want. Actionscript 2 by the way. :slight_smile:

Thanks for your help

How would I go about fading out the music though? I imagine that’s the hard part!

Try this:

your_clip.onMouseOut = function() {
   this.onEnterFrame = function() {
      this._alpha = this._alpha - 1;
      this.sound_name.volume = this.sound_name.volume - 1;
      if (this._alpha == 0) {
         stop(sound_name);
         delete this.onEnterFrame;
      }
   }
}

Many thanks with the help on the music! Will look into achieving this later.

In the meantime, now that I have achieved the visual interactivity, i now need to make this all a button. Unforunately, when I turn my Symbol into a button, I lose all of the interactivity!

My FLA is here.

Code I’m using is:

(one for title, one for background animation)

button.dundrumTitle.onRollOver  = function() {
   this.gotoAndPlay(2);
   dundrumMovie.gotoAndPlay(2);
}

button.dundrumTitle.onRollOut  = function() {
   this.gotoAndPlay(26);
}

What am I dong wrong?