TEXT RAIN EFFECT WITH ACTIONSCRIPT

 

This effect uses Movieclip property methods ,arrays and some math class to create a random text rain effect. The script attach different movieclips to the stage at random positions with definite names .Then we add motion to the these clips to create the same effect.

DOWNLOAD SOURCE

  • Create a new flash document by selecting file new flash document
  • Press Control + F8 or Insert >>New Symbol.

  • Give its name as textholder
  • Now click the advanced button to show advanced options and check the export for actionscript and export in first frame check boxes.
  • Now select the text tool and add a text filed and set the options as shown below

 

   
  • Go back to scene 1.
  • Add the code given below to the first frame of the movie.
    //creating a new empty movieclip
    this.createEmptyMovieClip("holder", this.getNextHighestDepth());
    //intializing variables within the new empty holder
    holder.maxnos =75;
    holder.dropspeed=1;
    var txt:MovieClip;
    /*|||||||loop to attach movieclips with diffrnt instance name to stage ||||||||*/
    for (i=0; i<holder.maxnos; i++) {
    holder.attachMovie("textholder", "textholder"+i, holder.getNextHighestDepth());
    //setting properities of the attached clip
    txt = holder["textholder"+i];
    txt._x =random(Stage.width);
    txt._y =random(Stage.height);
    txt._xscale = txt._yscale=random(60);
    //making a string containing the letters to be attached
    var txtsel:String="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrtuvwxyz";
    ranvalue=random(54);
    /*adding a letter at random index of the string to dynamic text field inside the attached clip*/
    txt.txt_char.text=txtsel.substr(ranvalue,1);
    }

    /*||||||||||function to add movement to the attached clips||||||||||||||*/
    holder.onEnterFrame = function() {
    for (i=0; i<this.maxnos; i++) {
    txt = this["textholder"+i];
    txt._y += txt._xscale*(this.dropspeed/100);
    txt._x += Math.sin((txt._y)/5);
    if (txt._y>Stage.height) {
    txt._y = 0;
    }
    }
    };

    EXPLANATION OF THE CODE NEXT PAGE

 
 
   
     

©2007 flashhelp.110mb.com