天天看点

flash动态文本加入省略号

 在动态文本中加入省略号

myWord = "欢迎来到webstudio.成立于2004年底,以FLASH APPLICATION为主,以FLASH DESIGN 为辅助的一个中型网站。旨在为国内的FLASH产业发展做一些力所能及的事"

String.prototype.shenglue = function (charactor:Number) {

return (substring (this, 0, charactor) + "......");

};

// --

this.createTextField ("my_txt", 1, 100, 100, 300, 300);

my_txt.multiline = true;

my_txt.wordWrap = true;

my_txt.html = true;

var my_fmt:TextFormat = new TextFormat ();

my_txt.text = myWord.shenglue (50);

my_txt.setTextFormat (my_fmt);

trace (myWord.shenglue (100));

非常简单的代码.只是为了在后面加6个点.......,方便之处在于可以任意选择断开文本的位置并自动加入省略号,如:

my_txt.text = myWord.shenglue (50);

输出结果为:

欢迎来到webstudio.成立于2004年底,以FLASH APPLICATION为主,以FLAS......

是在50个字符后加,可选在你想加的位置加入省略号.

如想在100个字符后加入,则为:

my_txt.text = myWord.shenglue (100);

本文转自:http://www.5uflash.com/flashjiaocheng/Flashaschengxu/298.html