2 Replies Latest reply on Apr 4, 2007 9:09 PM by Newsgroup_User

    onRollOver/Out animation

    abell06
      I have assigned the onRollOver and onRollOut event handlers for a movie clip to enact an alpha animation function on an interval, and it works, but only once.

      http://www.kustedg.com/lincoln.swf

        • 1. Re: onRollOver/Out animation
          Nick Barling Level 1
          You may need to use the clearInterval function after you have finished using the setInterval function.

          You could try adding this:

          clearInterval( intervalID );

          within the mc.EnterSite.onRollOver and mcEnterSite.onRollOut functions.

          regards

          Nick Barling
          www.barkingweb.com
          • 2. Re: onRollOver/Out animation
            Level 7

            > mcEnterSite.onRollOver = function():Void {
            > var nInterval:Number = setInterval(fadeIn, 10);
            > };
            > mcEnterSite.onRollOut = function():Void {
            > var nInterval:Number = setInterval(fadeOut, 10);
            >
            > };
            >
            > function fadeIn():Void {
            > mcWelcome._alpha++;
            > updateAfterEvent();
            > };
            > function fadeOut():Void {
            > mcWelcome._alpha--;
            > updateAfterEvent();
            > };
            >

            Nick is right, you need to clear the interval function.

            Basically a setInterval keeps running until the interval-id is cleared. So,
            you would probably be best off using a variable that is in the scope of the
            mcEnterSite... for instance.


            mcEnterSite.intervalId = 0;

            mcEnterSite.onRollOver = function():Void {
            clearInterval(mcEnterSite.intervalId);
            mcEnterSite.intervalId = setInterval(fadeIn, 10);
            };

            mcEnterSite.onRollOut = function():Void {
            clearInterval(mcEnterSite.intervalId);
            mcEnterSite.intervalId = setInterval(fadeOut, 10);
            };

            function fadeIn():Void {
            mcWelcome._alpha ++;
            updateAfterEvent();
            }

            function fadeOut():Void {
            mvWelcome._alpha --;
            updateAfterEvent();
            }