P
ROTOTYPE
I'm Not Only The Prototype, I'm Also A Member.
home
▪
stats
▪
search
▪
linkback
▪
about
▪
FAQ
| user: guest,
login
,
register
String
:
center justify text for pixel fonts
author:
cadrilo
[+]
,
Submitted: 01.28.03 3a
• Last Edit: 01.28.03 3a
String.prototype.centertext = function(clip, font, fsize, fcolor, numcar, theight, posx, posy) { words = new Array(); words = this.split(" "); count = 0; numline = 1; format = new TextFormat(); format.font = font; format.size = fsize; format.color=fcolor for (i=0; i<words.length; i++) { if ((count+words[i].length)>numcar) { this = this.substr(count); count = 0; numline++; _root[clip+".line"+numline] += " "+words[i]; } else { count = count+words[i].length+1; _root[clip+".line"+numline] += " "+words[i]; } } for (j=1; j<numline+1; j++) { _root[clip].createTextField("field"+j, j, posx, posy+j*theight, numcar*fsize, theight); tpath = "_root."+clip+".field"+j; with (eval(tpath)) { embedFonts = true; text = _root[clip+".line"+j]; setTextFormat(format); _x -= Math.round(textWidth/2); } } };
usage
Create a variable string where you put the entire text, for example "mytext" Create a MC where you put the text, for example "myclip" Import a pixel font to library and export it for actionscript with a name, for example: "myfont" mytext.centertext("myclip", "myfont", 8,0x55aa12, 40, 14, 150, 50);
Add Comment
[+]
›opyleft 2001-2010. Layer51 is: Jaime Prado.
@