鼠标跟随其实并不难,最简单的就是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部分可以自己修改,达到自己想要的效果。
作 者:custord
Java Asp PHP .Net XML C/C++ CGI VB Jsp J2ee J2se J2me EJB Servlet Tomcat Resin Struts Weblogic Eclipse ANT GUI JMS Web servise IDEA Webphere Hibernate Spring Jboss Applet Swing Socket Javamail Perl Ajax P2P 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器