Fading Tween

There are two ways to create tweens: using frame to frame animation and using actionscript. What is the advantage using actionscript? There are several advantages: filesize and easy manipulation by just changing numbers and tweens of dynamically loaded objects.

The actionscript tweens also seem to be dependent on the frame rate like frame to frame tweens. I found one disadvantage changing the width of an object with actionscript, which is that everything seems to slow down if the object is very big and you are using a modem. You can see an example of all tweens combined in the "Disco" movie.

The script for the alpha tween is shown below. As an example I have chosen static text.

          //main function with fadeSpeed as argument
MovieClip.prototype.fadeIn=function(fadeSpeed){
//we first set the object's alpha value to 0.
    mytext._alpha = 0;
//event handler
    this.onRollOver=function(){
          //defining the interval function
        myPause = new Object();
        myPause.interval = function() {
//if alpha is less than 100...
            if(mytext._alpha<100-fadeSpeed){
//alpha will be incremented by the fadespeed value.
                mytext._alpha+=fadeSpeed;
            } else {
//once reached alpha is 100 and interval is stopped.
                mytext._alpha = 100;
                clearInterval(myTimer);
            }           
        }
//starting the interval with 100 as the interval value
        myTimer = setInterval( myPause, "interval", 100);
    }
//the same again for fading out.
    this.onRollOut=function(){
        myPause = new Object();
        myPause.interval = function() {
            if(mytext._alpha<=100){
                mytext._alpha-=fadeSpeed;
            }else {         
                mytext._alpha = 0;
                clearInterval(myTimer);
            }           
        }
        myTimer = setInterval( myPause, "interval", 100);
    }   
}
button1.fadeIn(10); 

Continuation on the next page....

NEXT PAGE