·您的位置: 首页 » 资源教程 » 创意设计 » Flash » 三种鼠标跟随效果动画的实现

三种鼠标跟随效果动画的实现

类别: Flash教程  评论数:0 总得分:0
  先看效果

http://www.flash8.net/bbs/UploadFile/2005-6/200562412045497.swf

« Full Screen »


因为全是as编写的,所以我就不放源文件了,只要把as代码复制到flash里的第一帧就可以了

Stage.scaleMode = "noScale"
Stage.align = "TL"
for (i=1; i<=4; i++) {
_root.createEmptyMovieClip("point"+i, 0-i);//新建MC
//mc的x轴,y轴
_root["point"+i]._x = Stage.width/2;
_root["point"+i]._y = Stage.height/2;
//鼠标划过的效果
_root["point"+i].onMouseMove = function() {
this._x = _root._xmouse+(Math.random()*70)-35;
this._y = _root._ymouse+(Math.random()*70)-35;
};
}
//设定一个颜色组
hexColors = new Array("0xCC00FF", "0xCC33FF", "0xCC66FF", "0xCC99FF", "0xCCCCFF", "0xCCFFFF");
//鼠标划过时新建mc,并随机填充颜色和随机设alpha值
this.onMouseMove = function() {
i++;
this.createEmptyMovieClip("shape"+i, i *10);
with (this["shape"+i]) {
beginFill(hexColors[Math.floor(Math.random()*hexColors.length)], (Math.random()*40)+60);
//执行画线程序
moveTo(_root.point1._x, _root.point1._y);
curveTo(_root.point2._x, _root.point2._y, _root.point3._x, _root.point3._y);
curveTo(_root.point4._x, _root.point4._y, _root.point1._x, _root.point1._y);
endFill();
}
//复制当前mc,设X,Y轴,alpha值,并填充颜色,做为阴影。
this["shape"+i].duplicateMovieClip("shadow"+i, (10*i)-1);
this["shadow"+i]._x = this["shape"+i]._x -6;
this["shadow"+i]._y = this["shape"+i]._y + 6;
this["shadow"+i]._alpha = 60;
this.grey = new Color(this["shadow"+i]);
this.grey.setRGB("0x999999");
};

只做了简单的解释,适合有as基础的朋友学习

Stage.scaleMode = "noScale";
Stage.align = "TL";
for (i=1; i<=4; i++) {
_root.createEmptyMovieClip("point"+i, 0-i);
//新建MC
//mc的x轴,y轴
_root["point"+i]._x = Stage.width/2;
_root["point"+i]._y = Stage.height/2;
//鼠标划过的效果
_root["point"+i].onMouseMove = function() {
this._x = _root._xmouse+(Math.random()*70)-35;
this._y = _root._ymouse+(Math.random()*70)-35;
};
}
//设定一个颜色组
hexColors = new Array("0xCC00FF", "0xCC33FF", "0xCC66FF", "0xCC99FF", "0xCCCCFF", "0xCCFFFF");
//鼠标划过时新建mc,并随机填充颜色和随机设alpha值
this.onMouseMove = function() {
i++;
this.createEmptyMovieClip("shape"+i, i*10);
with (this["shape"+i]) {
beginFill(hexColors[Math.floor(Math.random()*hexColors.length)], (Math.random()*40)+60);
//执行画线程序
moveTo(_root.point1._x, _root.point1._y);
curveTo(_root.point2._x, _root.point2._y, _root.point3._x, _root.point3._y);
curveTo(_root.point4._x, _root.point4._y, _root.point1._x, _root.point1._y);
endFill();
}
//复制当前mc,设X,Y轴,alpha值,并填充颜色,做为阴影。
this["shape"+i].duplicateMovieClip("shadow"+i, (10*i)-1);
this["shadow"+i]._x = this["shape"+i]._x-6;
this["shadow"+i]._y = this["shape"+i]._y+6;
this["shadow"+i]._alpha = 60;
this.grey = new Color(this["shadow"+i]);
this.grey.setRGB("0x999999");
};
//加了一段删除的
var ii:Number = 6;
function del() {
if (_root["shape"+ii]) {
_root["shape"+ii].removeMovieClip();
_root["shadow"+ii].removeMovieClip();
ii++;
}
}
setInterval(del, 10);

  效果如下:

http://www.flash8.net/bbs/UploadFile/2005-6/200562418334546.swf

« Full Screen »



原来的其实更好看,越改越不好看了

import mx.transitions.Tween;
import mx.transitions.easing.*;
var i:Number = 0;
var mcname:Number = 0;
var x:Number = _xmouse, y:Number = _ymouse;
var rgb:Array = new Array("0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F");
var mousemove:Object = new Object();
mousemove.onMouseMove = function() {
fline();
};
function fline() {
var a:Number = Math.floor(Math.random()*16);
var b:Number = Math.floor(Math.random()*16);
var c:Number = Math.floor(Math.random()*16);
var d:Number = Math.floor(Math.random()*16);
var e:Number = Math.floor(Math.random()*16);
var f:Number = Math.floor(Math.random()*16);
var g:Number = Math.floor(Math.random()*6);
this.createEmptyMovieClip("line"+i, i);
mycolor = new Color(this["line"+i]);
mycolor.setRGB("0x"+rgb[a]+rgb[b]+rgb[c]+rgb[d]+rgb[e]+rgb[f]);
with (this["line"+i]) {
lineStyle(g, 0x0000, 100);
moveTo(x, y);
lineTo(_xmouse, _ymouse);
}
x = _xmouse;
y = _ymouse;
mcname_mc = this["line"+i];
i++;
}
setInterval(enterframes, 10);
function enterframes() {
if (_root["line"+mcname]) {
fdown(_root["line"+mcname]);
mcname++;
}
}
function fdown(mc_mc:MovieClip) {
var i:Number = mc_mc._y;
down = new Tween(mc_mc, "_y", Elastic.easeIn, i, i+200, 1, true);
down.onMotionStopped = function() {
mc_mc.removeMovieClip();
};
}
Mouse.addListener(mousemove);


原来的:
import mx.transitions.Tween;
import mx.transitions.easing.*;
var i:Number = 0;
var mcname:Number = 0;
var x:Number = _xmouse, y:Number = _ymouse;
var mousemove:Object = new Object();
mousemove.onMouseMove = function() {
fline();
};
function fline() {
var a:Number = Math.random()*5;
var b:Number = Math.random()*100;
this.createEmptyMovieClip("line"+i, i);
with (this["line"+i]) {
lineStyle(1, 0x0000, 100);
moveTo(x, y);
lineTo(_xmouse, _ymouse);
}
x = _xmouse;
y = _ymouse;
mcname_mc = this["line"+i];
i++;
}
setInterval(enterframes, 10);
function enterframes() {
if (_root["line"+mcname]) {
fdown(_root["line"+mcname]);
mcname++;
}
}
function fdown(mc_mc:MovieClip) {
var i:Number = mc_mc._y;
down = new Tween(mc_mc, "_y", Elastic.easeIn, i, i+200, 1, true);
down.onMotionStopped = function() {
mc_mc.removeMovieClip();
};
}
Mouse.addListener(mousemove);

  效果如下:

http://www.flash8.net/bbs/UploadFile/2005-6/20056240037515.swf

« Full Screen »



-= 资 源 教 程 =-
文 章 搜 索
关键词:
类型:
范围:
纯粹空间 softpure.com
Copyright © 2006-2008 暖阳制作 版权所有
QQ: 15242663 (拒绝闲聊)  Email: faisun@sina.com
 纯粹空间 - 韩国酷站|酷站欣赏|教程大全|资源下载|免费博客|美女壁纸|设计素材|技术论坛   Valid XHTML 1.0 Transitional
百度搜索 谷歌搜索 Alexa搜索 | 粤ICP备19116064号-1