• 【设为首页】
  • 【收藏闪客居】
当前位置:主页>AS 应用>文章内容
  • 纯代码文本框效果(as2.0)
  • 来源:闪吧 作者:smallerbird 2008-05-30 【

看看效果:

 

代码如下:

//------
//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")



上一篇:近乎完美的物理应用(as3.0)   下一篇:FLASH加载xml,txt,swf相关(as2.0)
  • 用户名:新注册) 密码: 匿名评论
  • 评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规)

Copyright © 2006-2008 flashas.net All Rights Reserved.
网站内容咨询: admin#flashas.net (#为@) 联系QQ:40777822 浙ICP备06033001号
(本网站最佳浏览解析度为1024*768, 建议使用IE 6.0或以上版本浏览器。)