Connecting Tech Pros Worldwide Forums | Help | Site Map

Fade movieclip on mouseout

toxicpaint's Avatar
Member
 
Join Date: Sep 2006
Posts: 58
#1: Jul 14 '09
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:
Expand|Select|Wrap|Line Numbers
  1. on (rollOut) {
  2.     function wait() {
  3.    var myInterval = setInterval(function () {        
  4.           _root.nigeria_text._visible = false;
  5.       clearInterval(myInterval);
  6.    }, 3*500);
  7. }
  8. wait();
  9. }
  10.  

Cheers,

Tom

toxicpaint's Avatar
Member
 
Join Date: Sep 2006
Posts: 58
#2: Aug 7 '09

re: Fade movieclip on mouseout


There must be an answer to this! Anyone? =/
Member
 
Join Date: May 2009
Posts: 81
#3: Aug 7 '09

re: Fade movieclip on mouseout


Quote:

Originally Posted by toxicpaint View Post

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.

Expand|Select|Wrap|Line Numbers
  1. // note that I just pulled this code out of thin air after 5+ years of having no contact with as2
  2. function fade_step()
  3. {
  4.     _root.nigeria_text.alpha -= 0.0334; // what happens on underflow?
  5.     updateAfterEvent(); // docs says you must call this
  6.     if(_root.nigeria_text.alpha > 0) setInterval(fade_step, 100);
  7. }
  8.  
  9. // call this once to begin fading
  10. setInterval(fade_step, 100);
  11.  
toxicpaint's Avatar
Member
 
Join Date: Sep 2006
Posts: 58
#4: Aug 7 '09

re: Fade movieclip on mouseout


Nice one. :)

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

Tags
fade, fade using actionscript, mouseout