鼠标跟随的制作

鼠标跟随其实并不难,最简单的就是startDrag(),配合mouse.hide()就可以改变鼠标在播放器内的样子,例如: onClipEvent(enterFrame){
mouse.hide()
startDrag(this,true)
}
好,稍微复杂一点,让鼠标移动的时候,后面会有几个mc跟着运动。
建立一个空白mc,用来放代码。建立3个key frame
frame1:
i=0
frame2:
if(i<=7){
duplicateMovieClip("_root.mc","_root.cm"+i,i);
}i++//复制mc
frame3:
if(i>=7){
i=0
}
gotoAndPlay(2)
运行一下试试:)
在复杂一点呢?让一些文字跟着鼠标运动呢?
xposition_Array=new Array()
yposition_Array=new Array()//定义两个数组,用来存放mouse的位置
myword = function(depth){
attachMovie("word","word" + depth,depth);
return this["word" + depth];
}//加载一个影片word,返回起name["word"+depth]
function mymouse (word_string, wordx)
{
if(wordx == undefined) this.lx = 20;
else this.lx = wordx;
this.string = word_string;
this.Read_String();
};//定义mymouse这个类,里面进行初试化
Mymouse.prototype.Read_String = function()
{
this.word_mc = new Array();
this.wordlenth = this.string.length;//wordlenth等于字符串长度
for (var i = 0; i < this.wordlenth; i ++) {
this.word_mc[i] = myword(i);//myword有
reture this["word"+depth],所以this.word_mc[i]就等于"word"+depth
this.word_mc[i].word = this.string.slice(i, i + 1);//从string中读取文字,写如this.word_mc[i]中的文本框word中
}
};
Mymouse.prototype.move = function (){
x_position=_root._xmouse
y_position=_root._ymouse
if(xposition_Array.length>=this.wordlength&&yposition_Array.length>=this.wordlength){
xposition_Array.shift()
yposition_array.shift()
xposition_Array.push(x_position)
yposition_Array.push(y_position)
}else{xposition_Array.push(x_position)
yposition_Array.push(y_position)
}
//将mouse的位置写入数组,记录下来
for(i=0;i<=this.wordlength-1;i++){
this.word_mc[i]._x=xposition_Array[this.wordlength-i-1]
this.word_mc[i]._y=yposition_Array[this.wordlength-
i-1]
}
for(i=0;i<=this.wordlenth-1;i++){
if(xposition_Array[i]==xposition_Array[i-1]&&yposition_Array[i]==yposition_Array[i-1]){
this.word_mc[i]._x=this.word_mc[i-1>._x+this.lx
}
}//定义鼠标静止后文字的位置
}
好,函数的定义部分就完成了,下面就新建一个图层写下
my_mouse = new Mymouse("我真的好爱你哦",20);
}
_root.onEnterFrame = function()
{
my_mouse.Mymove();
}
好了,运行一下试试 :) move部分可以自己修改,达到自己想要的效果。

转载于:https://www.cnblogs.com/savageworld/archive/2006/08/19/481395.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值