Thursday, 10 June 2010

Disappearing text effect class in AS3

I created the Disappearing text effect tutorial nearly a year ago. I used timeline animations to make the individual letters disappear one after another. I have decided to create a Disappearing text effect class to make the process of creating this text effect quicker. You will need to download the TweenLite plugin for this class. Below is the code.

package com.ilike2flash{

    import flash.display.MovieClip;
    import flash.events.Event;
    
    import com.greensock.*;

    public class DisappearText extends MovieClip {

        private var lettersArray:Array;
        private var counter:uint=0;
        
        public function DisappearText(lettArr:Array) {
            lettersArray=lettArr;
            setLetterFade();
            startFade();            
        }
            
        private function setLetterFade():void {
            for (var j:int=0; j
                lettersArray[j].alpha=0;
            }
        }

        private function startFade():void {
            TweenLite.to(lettersArray[counter],1,{alpha:1,onComplete:playNextFade});
        }

        private function playNextFade():void {
            if (counter==lettersArray.length-1 ) {
                counter=0;    
            }
            else {
                counter++;
                startFade();
            }
        }
    }
}


To use this class, you need to do step 1 & 2 of this tutorial. Then add all the movie clip instances to an array called mcArray and add the following code.
import com.ilike2flash.DisappearText;

var myDText:DisappearText = new DisappearText(mcArray);
addChild(myDText);

0 comments:

  COPYRIGHT © 2014 · ILIKE2FLASH · Theme by Ourblogtemplates

Back to TOP