Fade movieclip on mouseout

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • toxicpaint
    New Member
    • Sep 2006
    • 58

    Fade movieclip on mouseout

    Hi Everyone,

    I've had a look around but couldn't find any answers so thought I'd ask you lot. :)

    I'm using actionscript 2.0. What I have on my stage is a button that when you mouse over it, pops up a movie clip. Then when you move you mouse off it, it disappears after about 3 seconds. What I'd like it to do is fade out after 3 seconds rather than disappearing. For some reason this seems to be pretty much impossible with my existing code. Please help!

    This is what I have so far:
    Code:
    on (rollOut) {
    	function wait() {
       var myInterval = setInterval(function () {		
          	_root.nigeria_text._visible = false;
          clearInterval(myInterval);
       }, 3*500);
    }
    wait();
    }

    Cheers,

    Tom
  • toxicpaint
    New Member
    • Sep 2006
    • 58

    #2
    There must be an answer to this! Anyone? =/

    Comment

    • unauthorized
      New Member
      • May 2009
      • 81

      #3
      Originally posted by toxicpaint
      There must be an answer to this! Anyone? =/
      How about you just reduce the MovieClip's alpha property by 0.0334 every 100ms? Just make sure you disable it so your users won't click it again while it fades.

      Code:
      // note that I just pulled this code out of thin air after 5+ years of having no contact with as2
      function fade_step()
      {
          _root.nigeria_text.alpha -= 0.0334; // what happens on underflow?
          updateAfterEvent(); // docs says you must call this
          if(_root.nigeria_text.alpha > 0) setInterval(fade_step, 100);
      }
      
      // call this once to begin fading
      setInterval(fade_step, 100);

      Comment

      • toxicpaint
        New Member
        • Sep 2006
        • 58

        #4
        Nice one. :)

        Your message is too short please enter 20 characters or more.

        Comment

        Working...