[ 风筝教程 ]

教你做两种个性鼠标文字跟随

发表时间: 2008年02月11日 04时58分         评论/阅读(/)
本文地址: http://qzone.qq.com/blog/444269332-1202677133
本文已被推荐到Qzone社区, 点击了解更多精彩内容
      从一笑姐姐把文字跟随放在空间里面,到西西把怎么改源文件制作鼠标跟随的教程写在日志里,风筝一直很想学怎么做鼠标文字跟随.今天终于会了,过来和大家分享一下.

先来看看第一种,这种简单点:

我们来看看怎么做:
其实这个很简单就是写个代码到主场景就完了.代码:
aiyi_text = "这里改成你要输入的文字就好";
aiyi_len = aiyi_text.length;
n = 0;
while (n<aiyi_len) {
  _root.createEmptyMovieClip("aiyiT"+n, n);
  t = aiyi_text.substr(n, 1);
  with (_root["aiyiT"+n]) {
   createTextField("aiyi_t", 2, 0, 0, 20, 20);
   aiyi_t.text = t;
   //trace(aiyi_t.text)
  }
  n++;
}
startDrag(aiyiT0, true);
_root.onLoad = function() {
   speed = 3;
  };
_root.onEnterFrame = function() {
  aiyi = 1;
  while (aiyi<=_root.aiyi_len) {
   _root["aiyiT"+aiyi]._x += 5+(_root["aiyiT"+(aiyi-1)]._x-_root["aiyiT"+aiyi]._x)/speed;
   _root["aiyiT"+aiyi]._y += (_root["aiyiT"+(aiyi-1)]._y-_root["aiyiT"+aiyi]._y)/speed;
   aiyi++;
  }
};
_root.Mouse.hide();

详细做法:
1.新建flash文档,大小随意
2.点击动作打开动作面板:
3.写入代码:只要复制进去就好了,然后把框起来的地方改成你要跟随的字。

4.然后点控制测试影片就好了.

这个做法的缺点是不可以改字体,大小,颜色,也许可以在代码里面改,我不知道.你问兔子吧.或者到西西那里去看他的教程,点击进入.兔子的方法是一个字在一个图层,然后写代码.那个我也不知道,我也很期待看到.

再来看看第二种:

我们来看看怎么做的:
1.新建文档
2.插入,新建元件,

3.选择影片剪辑:

4.选用文本工具:

5.画个文本框,输入你想要的文字:

6.在下面的属性面板里面调节文字的颜色,字体,大小等!


7.把静态文本改成动态文本,变量里面写上word:



8.用选择工具拖动这个框框.让左边的中点和原点对齐:

9.用文字工具选中你输入的那些字,把刚刚输入的字删除掉。然后再外面点一下,会看到虚线框:

10.这样元件就编辑好了。返回主场景:

11.在右边的库里面右键元件1,然后点链接:

12.然后把ActionScript导出和在第一帧导出的勾勾上。在标识符里面写w:

13.打开动作面板,写入下面的代码,把你要输入的文字那里改成你想要的字: 
txt = "你要输入的文字";
tl = txt.length;
//获取文本长度
_root.attachMovie("w", "w", 1000);
//把库里的“字”放到场景
i = 1;
for (i; i<=tl; i++) {
duplicateMovieClip("w", "word"+i, i);
//复制库里的“字”(注意:库里的“字”需要先做连接)
_root["word"+i].word = txt.charAt(i-1);
//使“字”里的动态文本显示对应的文字
}
this.onEnterFrame = function() {
for (k=1; k<=tl; k++) {
  if (k == 1) {
   word1._y = (_ymouse+(word1._y-_ymouse)/1.15)+1;
   //第一个“字”比较特殊,需要特别设置。这里设置Y轴的缓冲移动
   word1._x = (_xmouse+(word1._x-_xmouse)/1.15)+2;
   //X轴运动
  } else {
   _root["word"+k]._y = (_root["word"+(k-1)]._y+(_root["word"+k]._y-_root["word"+(k-1)]._y)/1.15);
   //套用性的运动,设置第一个字以外的左右字的Y轴移动
   _root["word"+k]._x = (_root["word"+(k-1)]._x+(_root["word"+k]._x-_root["word"+(k-1)]._x)/1.15)+2.5;
   //X移动
  }
}
};

14.测试下影片就好了!祝你好运!

这样做可以改变字体大小颜色.但是我还是很想学习兔子的那种.

今天终于知道兔子那种怎么做的了,过来写下,相信还有很多人想知道吧:
1.打开flash,新建文档,大小随便设置下。
2.新建影片剪辑,方法:插入,新建元件,影片剪辑。(图我就不发了,上面有的)
3.在元件1里面写入你要跟随的第一个字,用文字工具。并且放在中间。用选取工具拖过去就可以了!(图片上面也有)
4.有必要的话下面属性里面的字体,颜色,大小改改。(上面也写了)
5.再新建影片剪辑,输入第二个字,和上面的步骤一样。
6.重复第五步直到达到你想要的字数。
7.返回场景,把刚刚建的元件全部拖入主场景。但是放到白色区域外面的灰色区域。

8.然后在属性面板里面写实例名,第一个字写t1,第二个字写t2,然后是t3,t4,t5,t6(注意哦,实例名一定要写对不然就只会有第一个字跟随的)

9.下面开始写代码,选中第一个字,右键动作,然后代码复制进去.也可以选中字然后点动作.( 图片不发了上面有)
10.和上面那步一样,把代码写进去.每个字一套代码,在下面! 然后测试下就完成了!

第一个字的代码:
onClipEvent (load) {
this._x = -2;
this._y = -2;
this._xscale = 80;
this._yscale = 80;
}
onClipEvent (enterFrame) {
if (this._x < _root._xmouse) {
  this._x = (this._x + (_root._xmouse - this._x) / 6) + 4;
  this._y = (this._y + (_root._ymouse - this._y) / 6) + 2;
}
if (this._x > _root._xmouse) {
  this._x = (this._x - (this._x - _root._xmouse) / 5) + 4;
  this._y = (this._y - (this._y - _root._ymouse) / 5) + 2;
}
}


第二个字的代码:
onClipEvent (load) {
this._x = -2;
this._y = -2;
this._xscale = 80;
this._yscale = 80;
}
onClipEvent (enterFrame) {
if (this._x < _root.t1._x) {
  this._x = (this._x + (_root.t1._x - this._x) / 6)+2 ;
  this._y = (this._y + (_root._ymouse - this._y) / 5) + 2;
  //this._y +=  (_root._ymouse - this._y) / 6;
}
if (this._x > _root.t1._x) {
  this._x = (this._x - (this._x - _root.t1._x) / 6) + 2;
  this._y = (this._y + (_root._ymouse - this._y) / 5) + 2;
  //this._y -=  (this._y - _root._ymouse) / 6;
}
}


第三个字的代码:
onClipEvent (load) {
this._x = -2;
this._y = -2;
this._xscale = 80;
this._yscale = 80;
}
onClipEvent (enterFrame) {
if (this._x < _root.t2._x) {
  this._x = (this._x + (_root.t2._x - this._x) / 7)+1.4 ;
  this._y = (this._y + (_root._ymouse - this._y) / 5) + 2;
  //this._y +=  (_root._ymouse - this._y) / 6;
}
if (this._x > _root.t2._x) {
  this._x = (this._x - (this._x - _root.t2._x) /7) + 1.4;
  this._y = (this._y + (_root._ymouse - this._y) / 5) + 2;
  //this._y -=  (this._y - _root._ymouse) / 6;
}
}

第四个字的代码:
onClipEvent (load) {
this._x = -2;
this._y = -2;
this._xscale = 80;
this._yscale = 80;
}
onClipEvent (enterFrame) {
if (this._x < _root.t3._x) {
  this._x = (this._x + (_root.t3._x - this._x) / 8)+1.3 ;
  this._y = (this._y + (_root._ymouse - this._y) / 5) + 2;
  //this._y +=  (_root._ymouse - this._y) / 6;
}
if (this._x > _root.t3._x) {
  this._x = (this._x - (this._x - _root.t3._x) / 8) + 1.3;
  this._y = (this._y + (_root._ymouse - this._y) / 5) + 2;
  //this._y -=  (this._y - _root._ymouse) / 6;
}
}


第五个字的代码:
onClipEvent (load) {
this._x = -2;
this._y = -2;
this._xscale = 80;
this._yscale = 80;
}
onClipEvent (enterFrame) {
if (this._x < _root.t4._x) {
  this._x = (this._x + (_root.t4._x - this._x) / 6)+1.3 ;
  this._y = (this._y + (_root._ymouse - this._y) / 5) + 2;
  //this._y +=  (_root._ymouse - this._y) / 6;
}
if (this._x > _root.t4._x) {
  this._x = (this._x - (this._x - _root.t4._x) / 6) + 1.3;
  this._y = (this._y + (_root._ymouse - this._y) / 5) + 2;
  //this._y -=  (this._y - _root._ymouse) / 6;
}
}


第六个字的代码:
onClipEvent (load) {
this._x = -2;
this._y = -2;
this._xscale = 80;
this._yscale = 80;
}
onClipEvent (enterFrame) {
if (this._x < _root.t5._x) {
  this._x = (this._x + (_root.t5._x - this._x) / 6)+1.3 ;
  this._y = (this._y + (_root._ymouse - this._y) / 5) + 2;
  //this._y +=  (_root._ymouse - this._y) / 6;
}
if (this._x > _root.t5._x) {
  this._x = (this._x - (this._x - _root.t5._x) / 6) + 1.3;
  this._y = (this._y + (_root._ymouse - this._y) / 5) + 2;
  //this._y -=  (this._y - _root._ymouse) / 6;
}
}

第七个字风筝也不知道, 这代码其实其他都一样,就是后面的坐标需要调一下,但是怎么调风筝就不知道了. 只要调X坐标轴,不要调Y坐标轴。



怎样使用上面制作好的鼠标跟随呢?
1.点击发布设置,发布。
2.进入下面这个网址:
http://hengtian.nyist.net/flash/admin/myupload.php
把刚刚发布好的flash上传
3.到http://hengtian.nyist.net/flash,在左边输入你刚刚上传得文件名搜索。
4.点击全屏播放,复制地址。

需要注意的是,这样做出来的文字跟随一定要导入背景模版里面使用,不然会出问题的(我上次春节做得鼠标跟随就那样失败了)

导入方法:
1.新建文档,设置文档大小为背景图片大小。
2.按照制作FD模块的方法处理下(详细请看怎样装扮空间之高级篇)右键分离,魔术棒选中,剪切
3.选中第一桢,右键动作,进入动作面板。
4.双击浏览器/网络中的 loadMovieNum,然后在括号中输入刚刚复制的flash地址,在地址左右加引号,在后面的引号后面加逗号,1。

如果你上面的看不懂或者觉得麻烦,直接复制下面的代码:
loadMovieNum("改成你的flash地址", 1);
然后发布就好了。

最好按照刚才的方法上传到网站上,进入下面这个网址: http://hengtian.nyist.net/flash/admin/myupload.php
把刚刚发布好的flash上传,到
http://hengtian.nyist.net/flash
在左边输入你刚刚上传得文件名搜索。点击全屏播放,复制地址。

最后在空间新建flash模块,输入flash地址就好了。详细见怎样装扮空间之初级篇


点击进入怎样免费装扮空间之初级篇
点击进入怎样免费装扮空间之中级篇
点击进入怎样免费装扮空间之高级篇
点击进入怎样用商城物品打造漂亮边框
点击进入制作按钮控制透明度补间动画
更多教程请到风筝教程专用空间点击进入
我空间的其他文章:
发表评论
日志新版升级特性介绍 请选择道具
温馨提示:点击验证码输入框,以获取验证码
请输入验证码:
  
Copyright ? 1998 - 2007 TENCENT Inc. All Rights Reserved 腾讯公司 版权所有