BrownEye
10-12-2006, 05:57 PM
Can you help me figure out how the did the text effect on this site when you rollover one of the buttons.
I am talking about the random text on rollover.
Thanks
Aaron
http://www.uniqlo.com/us/
ggreiner9
10-12-2006, 09:03 PM
hello, i did something similar to this before, check it out...
function crazyText(thisBox:TextField, myString:String, duration:Number, FPS:Number, animType:String):Void {
//made by ggreiner9@gmail.com
var myDepth = thisBox.getDepth()*-1;
var mcEnterFrame:MovieClip = this.createEmptyMovieClip("eFrame_mc"+myDepth, this.getNextHighestDepth());
var curFrame:Number = 1;
var letterFrame:Number = (duration*FPS)/myString.length;
var minusNum:Number = 0;
var myFinalString:String = "";
var myArray:Array = new Array();
for (x=0; x<myString.length+1; x++) {
myArray[x] = myString.charAt(x);
}
//
this["eFrame_mc"+myDepth].onEnterFrame = function() {
thisBox.text = "";
var myFinalNum:String = "";
if (curFrame<(duration*FPS)) {
setLetter = Math.floor(curFrame%letterFrame);
if (setLetter == 0) {
myFinalString += myArray[minusNum];
minusNum += 1;
}
for (x=0; x<(myString.length)-minusNum; x++) {
if (animType == "Letters(UCase)") {
this["rdmNum"+x] = Math.round(Math.random()*(89-65+1)+65);
myFinalNum += String.fromCharCode(this["rdmNum"+x]);
} else if (animType == "Letters(LCase)") {
this["rdmNum"+x] = Math.round(Math.random()*(121-97+1)+97);
myFinalNum += String.fromCharCode(this["rdmNum"+x]);
} else if (animType == "Numbers") {
this["rdmNum"+x] = Math.round(Math.random()*9);
myFinalNum += String(this["rdmNum"+x]);
} else if (animType == "Random Characters") {
this["rdmNum"+x] = Math.round(Math.random()*255);
myFinalNum += String.fromCharCode(this["rdmNum"+x]);
}
}
thisBox.text += myFinalString+String(myFinalNum);
curFrame += 1;
} else if (curFrame == (duration*FPS)) {
thisBox.text = myString;
delete (this["eFrame_mc"+myDepth].onEnterFrame);
}
};
}
if you want certain characters, you'll just have to know what their unicode number is(im not too familiar with this, but i remember i found a chart listing all of the number a long time ago). Then you can make that random number what ever you want.
the parameters are pretty much self explanatory, the duration is in seconds and the FPS is the FPS of your movie(i didnt know how to get that using actionscript, so if you know how that can be fixed), the animType(animation type) can be "Numbers", "Letters(UCase)", "Letters(LCase)", "Random Characters", offcourse you can change whatever you want and make it your own.
ps: sorry if the code is kinda messy but i made this when i didnt know how to keep my code clean, and stuff lol
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.