Flash简单的鼠标跟随的文字动画实例
程序员文章站
2022-05-24 19:20:15
[效果]:
[步骤]:
1、拉一动态文本,实例名为_txt;转为影片剪... 08-10-13...
[效果]:
[步骤]:
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;
}
[步骤]:
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;
}
上一篇: win7系统删除文件提示正在准备再循环的多种解决方法
下一篇: 搜索引擎秒收实例经验分享图文教程