SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    68
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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!

  2. #2
    SitePoint Evangelist ferrari_chris's Avatar
    Join Date
    Mar 2008
    Location
    NP, New Zealand
    Posts
    576
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can set the onMouseOver event of the MovieClip you want to target to get it to start playing.

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

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

    Code Actionscript:
    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.

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    68
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your help

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

  4. #4
    SitePoint Evangelist ferrari_chris's Avatar
    Join Date
    Mar 2008
    Location
    NP, New Zealand
    Posts
    576
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ZernanToledo View Post
    Thanks for your help

    How would I go about fading out the music though? I imagine that's the hard part!
    Try this:

    Code Actionscript:
    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;
          }
       }
    }

  5. #5
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    68
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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)

    Code:
    button.dundrumTitle.onRollOver  = function() {
       this.gotoAndPlay(2);
       dundrumMovie.gotoAndPlay(2);
    }
    
    button.dundrumTitle.onRollOut  = function() {
       this.gotoAndPlay(26);
    }
    What am I dong wrong?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •