| 首页 | 新闻 | 网页 | 设计 | 色彩 | 原创 | 视觉 | 素材 | 动漫 | 酷站 | 策划 | 文案 | 访谈 | 运营 | 编程 | 数据库 | 服务器 | 下载 | 图库 | 
您的位置: 幽幽天空 > 网页 > 网页制作 > Flash教程 > ActionScript教程 > 文章正文 用户登录
跟随鼠标的萤火虫
各种漂亮的鼠标UR
更改鼠标样式
鼠标后面跟随彩色
个性化鼠标右键内
如何用鼠标左右键
Flash中的鼠标绘画
Flash中的鼠标绘画
mc的本地坐标和舞
简单的检测鼠标是

鼠标和mc的位置关系           

鼠标和mc的位置关系

作者:佚名 来源:闪吧 作者: holybozo 更新:2007-1-13 20:47:16 错误报告 我要投稿

这个效果很滥了,之前只是想着觉得挺简单,自己一着手就卡住了,好像还是被初中数学卡住的,哭一个,哎~实在不好意思拿出来做教程,就当给大家分享一下吧,程序惨不忍睹,想到哪里编到哪里~~

点击开新窗口欣赏该FLASH动画![全屏欣赏]

按此在新窗口浏览图片


/****************************
* 鼠标控制图片移动实例 *
*****************************/
////////////////////////////////
//初始化数据//
var leftest = 50;
var rightest = 350;
var startX = -50;
var startY = -3;
var click = false;
var nowTime = 0;
////////////////////////////////
//加载相关元件//
_root.attachMovie("mouseHand", "hand", 1000);
hand._x = _root._xmouse;
hand._y = _root._ymouse;
_root.attachMovie("myPic", "pic", 11);
pic._x = startX;
pic._y = startY;
pic._xscale = pic._yscale=60;
_root.createEmptyMovieClip("screen", 10);
with (screen) {
lineStyle(1, 0x000000, 0);
beginFill(0x000000, 100);
moveTo(leftest, 0);
lineTo(rightest, 0);
lineTo(rightest, 200);
lineTo(leftest, 200);
lineTo(leftest, 0);
}
pic.setMask(screen);
////////////////////////////////
//鼠标跟随//
startDrag("hand", true, leftest, 0, rightest, 200);
Mouse.hide();
////////////////////////////////
//图片控制//
var oldX = _root._xmouse;
var hSpeed = 3;//图片移动速度
var zSpeed = 1;//图片放大速度
Mouse.addListener(_root);//定义监听器
_root.onMouseDown = function() {
click = true;
hand.gotoAndStop("click");
var oldWidth = pic._xscale;
var oldHeight = pic._yscale;
var mouseX = _root._xmouse;
var mouseY = _root._ymouse;
var picX = pic._x;
var picY = pic._y;
var moveX, moveY;
pic.onEnterFrame = function() {
if (this._xscale<100 || this._yscale<100) {
//图片放大
this._xscale += zSpeed;
this._yscale += zSpeed;
//图片以鼠标点击位置为中心放大时,图片坐标的移动
moveX = ((mouseX-picX)/oldWidth*this._xscale+picX)-mouseX;
moveY = ((mouseY-picY)/oldHeight*this._yscale+picY)-mouseY;
this._x = picX-moveX;
this._y = picY-moveY;
} else {
delete this.onEnterFrame;
}
};
};
_root.onMouseUp = function() {
publicAS();
pic.onEnterFrame = function() {
//图片缩小为初始状态
if (this._xscale>60 || this._yscale>60) {
this._xscale += (60-this._xscale)/10;
this._yscale += (60-this._yscale)/10;
this._x += (startX-this._x)/10;
this._y += (startY-this._y)/10;
} else {
delete this.onEnterFrame;
}
};
};
////////////////////////////////
//控制图片//
_root.onEnterFrame = function() {
//鼠标花絮//
var elapse = getTimer()-nowTime;
if (elapse-3000>=0 && !click) {
elapse = 0;
click = true;
nowTime = getTimer();
hand.gotoAndPlay(2);
}
//左移右移//
var nowX = _root._xmouse;
if (((oldX-nowX)<0 || nowX>=rightest) && (pic._x+pic._width)>350) {
//鼠标右移,图片左移
pic._x -= hSpeed;
publicAS();
}
if (((oldX-nowX)>0 || nowX<=leftest) && pic._x<50) {
//鼠标左移,图片右移
pic._x += hSpeed;
publicAS();
}
oldX = _root._xmouse;
};
//一些公用的代码
function publicAS() {
hand.gotoAndStop(1);
nowTime = getTimer();
click = false;
}

-源文件下载-

文章录入:skyuu    责任编辑:skyuu 
  • 上一篇文章:

  • 下一篇文章:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
    网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)
    发表评论:
    姓名:  评 分: 1分 2分 3分 4分 5分
     
  • 严禁发表危害国家安全、政治、黄色淫秽等内容的评论。
  • 用户需对自己在使用幽幽天空服务过程中的行为承担法律责任。
  • 本站管理员有权保留或删除评论内容。
  • 评论内容只代表机友个人观点,与本网站立场无关。