[效果]:
[步骤]:
1、拉一动态文本,实例名为_txt;转为影片剪辑,实例名为_mc。
2、在帧上写如下代码:
txt_array = ["琴", "者", "工", "作", "室"];
//跟随鼠标的文字定义为数组中的元素
for (j=0; j<5; j ) {
_mc.duplicateMovieClip("_mc" j, j 100);
this["_mc" j]._txt.text = txt_array[j];
//复制影片剪辑并使动态文本中的内容为对应数组中的元素
this["_mc" j]._txt.autoSize = true;
this["_mc" j]._txt.selectable = false;
//设置动态文本
this["_mc" j].vx = this["_mc" j].vy=0;
//初始化影片剪辑的变量vx、vy值均为0
}
onEnterFrame = function () {
mcxy(_mc0, _xmouse, _ymouse);
for (j=1; j<5; j ) {
mcxy(this["_mc" j], this["_mc" (j-1)]._x, this["_mc" (j-1)]._y);
}
};
//运行每一帧时影片剪辑的坐标执行如下自定义函数
function mcxy(_mc, a, b) {
_mc.vx = (a-_mc._x)*.5;
_mc.vy = (b-_mc._y)*.5;
_mc.vx *= .5;
_mc.vy *= .5;
_mc.vx = 4;
_mc._x = _mc.vx;
_mc._y = _mc.vy;
}