TextField.prototype.constructTextbyLetter = function(txt, speed, size) { if (!size) { size = 1; } if (!speed) { speed = 10; } var i = 0; var txt = txt; clearInterval(_root[this._name+'Int']); _root[this._name+'Int'] = setInterval(function (_txt) { // from start //_txt.text = txt.substr(0, (i+=size)) // from start with acceleration _txt.text = txt.substr(0, _txt.length+(i += size)); // from end //_txt.text = txt.substr(txt.length-(i+=size)) // from end with acceleration //var first_letter = txt.length-(_txt.length+(i+=size)) //_txt.text = txt.substr((first_letter < 0 ? 0 : first_letter)) // updateAfterEvent(); if (_txt.length>=txt.length) { clearInterval(_root[_txt._name+'Int']); } }, speed, this); }; TextField.prototype.deConstructTextbyLetter = function(speed, size) { if (!size) { size = 1; } if (!speed) { speed = 10; } var i = 0; var len = this.length; clearInterval(_root[this._name+'Int']); _root[this._name+'Int'] = setInterval(function (_txt) { // from end //_txt.text = _txt.text.substr(0, len-(i+=size)) // from end with acceleration //_txt.text = _txt.text.substr(0, _txt.length-(i+=size)) // from start //_txt.text = _txt.text.substr(size) // from start with acceleration _txt.text = _txt.text.substr((i += size)); updateAfterEvent(); if (!_txt.length) { clearInterval(_root[_txt._name+'Int']); } }, speed, this); };
Usage:
//Create a textfield in the main timeline, name it to test, make it dynamic. //put this code to your _root. test.constructTextbyLetter("Another sample text .", 100, 3); // or test.constructTextbyLetter("Another sample text .", 100); //Deconstruct: test.constructTextbyLetter(100);


