PDA

View Full Version : letter fading


stealthelephant
07-29-2003, 02:06 PM
how do i fade text in a dynamic text field? i attach code to fade it, the text box fades but not the text inside it, is there a way to do it?

JGizmo
07-29-2003, 02:20 PM
I find this code which can help you in search of the matrix :D /***Author: Ilyas USAL (pom)
Title: The Matrix has you...
Date: 06/06/2003
***/

// To make it run smoother
_quality = "MEDIUM";

/*** Functions ***/
// fade out and stop when _alpha inferior to 35 - no parameters
function fadeOut(){
this._alpha -= 5;
if (this._alpha < 45) delete this.onEnterFrame;
}
// fade out and remove clip when _alpha inferior to 10 - no parameters
function fadeToBlack(){
this._alpha -= 5;
if (this._alpha < 10){
delete this.onEnterFrame;
this.removeMovieClip();
}
}
// Create a new clip with a letter in it
// x: _x position ; y: _y position ; size: size of the letter
MovieClip.prototype.createLetter = function (x,y,size){
// Create and position the new clip
var mc = this.createEmptyMovieClip("letter"+this.dep,this.dep++);
mc._x = x;
mc._y = y;
// Create a new TextField in the clip
mc.createTextField("t",0,0,0,size,size);
// Choose a random letter
var myChar = Math.round(Math.random()*87)+36;
mc.t.text = chr(myChar);
// Create the TextFormat, format the text and embed the font
var tf = new TextFormat();
tf.size = size;
tf.font = "Courier New";
tf.selectable = false;
tf.color = "0x00ff00";
mc.t.setTextFormat(tf);
mc.t.embedFonts = true;
// Fade the letter until its _alpha = 35
mc.onEnterFrame = fadeOut;
}
// Create a trail of letters
function createTrail(){
// Create new clip and position it randomly
var clip = this.createEmptyMovieClip("trail"+i,i++);
clip._x = Math.round(random(Stage.width)/10)*10;
clip._y = clip.y = -10;
// Choose a random size for the letters, and set the spacing
var size = random(10)+15;
clip.spacing = size + 2;
// onEnterFrame, create a new letter that will wade out.
// if we're at the bottom of the screen, fade out the whole trail
clip.onEnterFrame = function(){
this.y += this.spacing;
this.createLetter(0,this.y,size);
if (this.y > Stage.height) this.onEnterFrame = fadeToBlack;
}
}
// Create a new trail every 100 milliseconds
setInterval(this,"createTrail",100);Key is: fading the movieclip which contains the textfield not the text itself.

stealthelephant
07-29-2003, 02:25 PM
i'm a dumbass, i was thinking about something else and talking about another:confused:

i think i will stay with my own, kinda far into it at the moment, hope it doesnt run to heavily on the cpu though

thanx for the code though, i will look at it anyways