这里提供了大家怎么制作虚线的输入文本, 希望大家可以好好的应用技巧... 新手请先从底下看起, 不然你们根本拿了也不知道怎么修改
MovieClip.prototype.dashTo = function(startPoint, destPoint, dashLength, spaceLength, strok0x, strokWi) { //计算出x, y和距离等所需要的值
var x = destPoint.x - startPoint.x;
var y = destPoint.y - startPoint.y;
var hyp = Math.sqrt((x)*(x) + (y)*(y));
var units = hyp/(dashLength+spaceLength);
var dashSpaceRatio = dashLength/(dashLength+spaceLength);
var dashX = (x/units)*dashSpaceRatio;
var spaceX = (x/units)-dashX;
var dashY = (y/units)*dashSpaceRatio;
var spaceY = (y/units)-dashY; //开始设定线的Style
this.lineStyle(strokWi, strok0x, 100); //设定开始画线的位置
this.moveTo(startPoint.x, startPoint.y); //使用循环画线一直到结束并输出 :)
while (hyp > 0) {
startPoint.x += dashX;
startPoint.y += dashY;
hyp -= dashLength;
if (hyp < 0) {
startPoint.x = destPoint.x;
startPoint.y = destPoint.y;
}
this.lineTo(startPoint.x, startPoint.y);
startPoint.x += spaceX;
startPoint.y += spaceY;
this.moveTo(startPoint.x, startPoint.y);
hyp -= spaceLength;
}
this.moveTo(destPoint.x, destPoint.y);
}
MovieClip.prototype.newCreateTextField = function(naim, d, x, y, w, h, dLength, sLength, strok0x, strokWi){ //所传递过来的参数先使用前6个参数建立个文本
this.createTextField(naim, d, x, y, w, h); if(dLength!=undefined){ //这里是方便大家, 要是没有设定后面的4个参数, 就使用预设值
if(sLength == undefined)sLength = 5;
if(strok0x == undefined)strok0x = 0xFF0000;
if(strokWi == undefined)strokWi = 1; //上面建立了文本之后就是来开始画线了, 再建立一个prototype dashTo, 当中传递的参数(开始坐标, 结束坐标, 和之前传递过来的最后4个参数)
this.dashTo({x:x, y:y+h}, {x:x+w, y:y+h}, dLength, sLength, strok0x, strokWi);
}
}
//首先是从这里开始...先建立一个prototype叫newCreateTextField()的, 这里的参数是 (实例名, 深度, x坐标, y坐标, 宽度, 高度, 线长度, 空隙长度, 虚线颜色, 线粗) //前面6个参数和普通的建立文本是一样的, 后面的4个参数是设定虚线所需要的参数 this
.newCreateTextField("myText", 10, 100, 100, 200, 20, 5, 2, 0xFF0000, 1);
myText.type = "input";
myText.text = "底线输入文本";