5D艺术网首页
商城
|
资讯
|
作品
|
博客
|
教程
|
论坛
登录
注册
加为好友
发短消息
来自:
性别:秘密
最后登录:2007-09-22
http://yuheduo.5d.cn/
首页
|
新闻
|
话题
|
博客
|
相册
|
艺术作品
|
社交关系
|
留言板
|
社交圈
2005/07/21 | 又做了一个鼠标跟随效果(努力学习)
类别(Flash学习)
|
评论
(2)
|
阅读(213)
|
发表于 22:32
效果如下
源文件下载
---------------下面是代码说明---------------------
for (var i = 1; i<=10; i++) {
//attach 5个mc,并有一个num属性放他们的序号
aa = attachMovie("all", "mc"+i, i, {num:i , _alpha:100-8*i});
aa.steep=0.4;
aa.steep2=0.5;//相当于"摩擦力系数"
aa.vx=0;
aa.vy=0;
aa.gotoAndStop(i);
aa.onEnterFrame = function() {
//mycolor=new Color();
mycolor=new Color(this);
mycolor.setRGB(random(0xffffff));
//第一个attach的mc(num==0的那个)跟随鼠标
if (this.num == 1) {
this.targetx = _root._xmouse;
this.targety = _root._ymouse
} else {
//否则跟随他的前一个(num-1)
this.targetx = eval("mc"+(this.num-1))._x;
this.targety = eval("mc"+(this.num-1))._y;
}
//缓冲~~~
this.vx=(this.targetx-this._x)*this.steep+this.vx*this.steep2;
this.vy=(this.targety-this._y)*this.steep+this.vy*this.steep2;
this._x+=this.vx;
this._y+=this.vy;
};
}
0
评论
Comments
日志分类
首页
[149]
blog记事
[7]
Flash学习
[85]
教学记忆
[21]
娱乐影音
[9]
我的收藏
[27]
PhotoShop学习
[0]