cambialo con questo




function charPositions(tFormat, str, depth) {
_root.createTextField("temp", depth, 0, -300, 100, 400);
temp.autosize = true;
temp.embedFonts = true;
temp.setNewTextFormat(tFormat);
var arr = [];
temp.text = str;
var totalWidth = temp.textWidth;
for (var i = 0; i<str.length; i++) {
temp.text = str.substr(i);
arr[i] = totalWidth-temp.textWidth;
}
return arr;
}
function setUpText(str, forma, lineLength) {
var positions = charPositions(forma, str, 2000);
var currentLine;
var lineHeight = forma.getTextExtent(str).height;
var finalPositions = [];
for (var i = 0; i<positions.length; i++) {
if (positions[i]>(lineLength+subtracta)) {
subtracta = positions[i];
currentLine++;
}
var x = positions[i]-subtracta;
var y = lineHeight*currentLine;
finalPositions[i] = {char:str.charAt(i), x:x, y:y};
}
return finalPositions;
}
function drawNext() {
var noo = this.createEmptyMovieClip("lett"+this.count, this.count);
var nextObj = charPos[this.count];
noo._x = nextObj.x;
noo._y = nextObj.y;
noo.createTextField("tex", 1, 0, 0, 100, 100);
noo.tex.text = nextObj.char;
noo.tex.embedFonts = true;
noo.tex.selectable = false;
noo.tex.setTextFormat(mt);
noo._alpha = 30;
noo.onEnterFrame = function() {
this._alpha += 5;
if (this._alpha>=500) {
this.onEnterFrame = function() {
lunghezza = length(str);
if (_root["lett"+lunghezza]._alpha<0) {
init(str, mt, 520);
}
if (this._alpha>=0) {
this._alpha -= 5;
} else if (this._alpha<0) {
delete this.onEnterFrame;
}
};
}
};
this.count++;
if (this.count>charPos.length) {
delete this.onEnterFrame;
}
}
function init(str, tForm, lineLength) {
charPos = setUpText(str, tForm, lineLength);
this.count = 0;
this.onEnterFrame = drawNext;
}
mt = new TextFormat();
mt.font = "Arial";
mt.size = 24;
mt.color = 0xffffff;
mt.bold = true;
str = "ciao da emanuel";
init(str, mt, 520);
stop();