发新话题
打印

[编程] 纯代码文本框的效果

纯代码文本框的效果

看看效果


代码如下:

//------
//root:MovieClip 文本mc
//targetMc:MovieClip 参照物mc
//numLen:Number 显示的字数
//strText:String 显示的内容
//createOneTxt(root:父影片,strTxtName:文本mc名称,numX:Number,numY:Number,numW:Number,numH:Number,numLen:显示的字数,strText:显示的内容)
//--------/
function createOneTxt(root:MovieClip,targetMc:MovieClip,numLen:Number, strText:String):Void {
var numX:Number,numY:Number,numW:Number,numH:Number
numX=targetMc._x;
numY=targetMc._y;
numW=targetMc._width;
numH=targetMc._height;
//
targetMc._alpha=0;
//
root._x = numX;
root._y = numY;
root.createTextField("my_txt", 1, 0, 0, numW, numH);
with (root) {
//my_txt.multiline = true;
my_txt.wordWrap = true;
//my_txt.border = true;
//my_txt.autoSize = true;
//是否显示详细
if (strText.length>numLen) {
my_txt.text = strText.substring(0, numLen);
//
root.onRollOver = function() {
//调换深度
this.swapDepths(root[root.MaxDepth]);
root.MaxDepth = this._name;
//
this.createEmptyMovieClip("mcTxt", this.getNextHighestDepth());
this.mcTxt._x = 0;
this.mcTxt._y = 0;
this.mcTxt.createTextField("Temmy_txt", this.getNextHighestDepth(), 0, 0, numW, numH);
this.mcTxt.Temmy_txt.multiline = true;
this.mcTxt.Temmy_txt.wordWrap = true;
this.mcTxt.Temmy_txt.border = true;
this.mcTxt.Temmy_txt.autoSize = true;
this.mcTxt.Temmy_txt.background = 0xFFffff;
this.mcTxt.Temmy_txt.text = strText;
};
root.onRollOut = function() {
this.mcTxt.Temmy_txt.removeTextField();
};
} else {
my_txt.text = strText;
}
}
}
//生成两个方框。
//smallerbird 2007-10-30
//flash原创代码尽在 www.MyGameMyLove.com
//mcTarA,mcTarB 就是两个文本框出现的位置
_root.createEmptyMovieClip("mcTxt1",_root.getNextHighestDepth());
createOneTxt(mcTxt1,mcTarA,22,"你的苦难就是我们的苦难,你的希望就是我们的希望。当灾难来临时,我们与你在一起,一起为逝者默念安息、一起为伤者祈祷平安。而更多的关怀和力量,正悄悄在汇集:天佑中华,众志成城;抗震救灾、重建家园...... ")
//
_root.createEmptyMovieClip("mcTxt2",_root.getNextHighestDepth());
createOneTxt(mcTxt2,mcTarB,100,"2008-5-12")

TOP

呵呵,谢谢

TOP

dingding

dingding

TOP

高薪诚聘!!!深圳市iLemon网络科技高薪诚聘WebGame程序开发人才加盟

提示: 作者被禁止或删除 内容自动屏蔽

TOP

发新话题