Flash8.0 怎样让元件随鼠标移动
怎样让元件随鼠标移动例如做FPS的flash时让准星随鼠标移动如果让元件隔一定距离随鼠标移动该怎样做?例如枪支与准星谢谢...
怎样让元件随鼠标移动例如做FPS的flash时 让准星随鼠标移动 如果让元件隔一定距离随鼠标移动 该怎样做?例如 枪支与准星谢谢
展开
推荐于2016-03-13
展开全部
建一个mc实例名mouse
以下代码加在帧上:
_root.onEnterFrame = function() {
Mouse.hide(); //隐藏鼠标
_root.mouse._x = _xmouse; //mc的x坐标等于鼠标x的坐标
_root.mouse._y = _ymouse; //mc的y坐标等于鼠标的y坐标
};
如果让元件隔一定距离随鼠标移动:
可以写:
_root.onEnterFrame = function() {
Mouse.hide(); //隐藏鼠标
_root.mouse._x = _xmouse-20; //mc的x坐标等于鼠标x的坐标-20
_root.mouse._y = _ymouse-20; //mc的y坐标等于鼠标的y坐标-20
};
如果让鼠标显示就写:Mouse.show();
以下代码加在帧上:
_root.onEnterFrame = function() {
Mouse.hide(); //隐藏鼠标
_root.mouse._x = _xmouse; //mc的x坐标等于鼠标x的坐标
_root.mouse._y = _ymouse; //mc的y坐标等于鼠标的y坐标
};
如果让元件隔一定距离随鼠标移动:
可以写:
_root.onEnterFrame = function() {
Mouse.hide(); //隐藏鼠标
_root.mouse._x = _xmouse-20; //mc的x坐标等于鼠标x的坐标-20
_root.mouse._y = _ymouse-20; //mc的y坐标等于鼠标的y坐标-20
};
如果让鼠标显示就写:Mouse.show();
2013-09-02
展开全部
只要把以下代码复制到FLASH8的动作帧里就可以啦
代码如下:
function 鼠标跟随(myString, a, b, c, txtspeed)
{
Mouse.hide();
var i = 0;
while (i < String_num)
{
this["dx" + i] = 0;
this["dy" + i] = 0;
var mc = _root.createEmptyMovieClip("txt" + i, i);
this["color" + i] = new Color(mc);
with (mc)
{
_xscale = _yscale = txtspeed;
createTextField("mytxt", i, 0, 0, 0, 0);
mytxt.autoSize = true;
mytxt.text = myString.substr(i, 1);
} // End of with
++i;
} // end while
_root.onEnterFrame = function ()
{
txt0._x = _root._xmouse;
txt0._y = _root._ymouse;
for (var _loc3 = 0; _loc3 < String_num; ++_loc3)
{
this["color_from" + _loc3] = {ra: 5 * _loc3, rb: 255 - 2 * _loc3, ga: _loc3 * 20 - 100, gb: Math.floor(Math.random() * 500 - 255), gb: 100 - 20 * _loc3, ba: 5 * _loc3 - 50, bb: Math.floor(Math.random() * 500 - 255)};
this["color" + _loc3].setTransform(this["color_from" + _loc3]);
this["dx" + _loc3] = this["dx" + _loc3] * a + (this["txt" + (_loc3 - 1)]._x + c - this["txt" + _loc3]._x) * b;
this["dy" + _loc3] = this["dy" + _loc3] * a + (this["txt" + (_loc3 - 1)]._y - this["txt" + _loc3]._y) * b;
this["txt" + _loc3]._x = this["txt" + _loc3]._x + this["dx" + _loc3];
this["txt" + _loc3]._y = this["txt" + _loc3]._y + this["dy" + _loc3];
} // end of for
};
} // End of the function
var myString = "我的FLASH";
var a = 6.500000E-001;
var b = 1.000000E-001;
var c = 15;
var txtspeed = 150;
var String_num = myString.length;
鼠标跟随(myString, a, b, c, txtspeed);
打击复制代码粘在动作帧里!没问题就可以提取了,导出影片
代码如下:
function 鼠标跟随(myString, a, b, c, txtspeed)
{
Mouse.hide();
var i = 0;
while (i < String_num)
{
this["dx" + i] = 0;
this["dy" + i] = 0;
var mc = _root.createEmptyMovieClip("txt" + i, i);
this["color" + i] = new Color(mc);
with (mc)
{
_xscale = _yscale = txtspeed;
createTextField("mytxt", i, 0, 0, 0, 0);
mytxt.autoSize = true;
mytxt.text = myString.substr(i, 1);
} // End of with
++i;
} // end while
_root.onEnterFrame = function ()
{
txt0._x = _root._xmouse;
txt0._y = _root._ymouse;
for (var _loc3 = 0; _loc3 < String_num; ++_loc3)
{
this["color_from" + _loc3] = {ra: 5 * _loc3, rb: 255 - 2 * _loc3, ga: _loc3 * 20 - 100, gb: Math.floor(Math.random() * 500 - 255), gb: 100 - 20 * _loc3, ba: 5 * _loc3 - 50, bb: Math.floor(Math.random() * 500 - 255)};
this["color" + _loc3].setTransform(this["color_from" + _loc3]);
this["dx" + _loc3] = this["dx" + _loc3] * a + (this["txt" + (_loc3 - 1)]._x + c - this["txt" + _loc3]._x) * b;
this["dy" + _loc3] = this["dy" + _loc3] * a + (this["txt" + (_loc3 - 1)]._y - this["txt" + _loc3]._y) * b;
this["txt" + _loc3]._x = this["txt" + _loc3]._x + this["dx" + _loc3];
this["txt" + _loc3]._y = this["txt" + _loc3]._y + this["dy" + _loc3];
} // end of for
};
} // End of the function
var myString = "我的FLASH";
var a = 6.500000E-001;
var b = 1.000000E-001;
var c = 15;
var txtspeed = 150;
var String_num = myString.length;
鼠标跟随(myString, a, b, c, txtspeed);
打击复制代码粘在动作帧里!没问题就可以提取了,导出影片
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2013-09-02
展开全部
我也想知道怎么做,这些代码看得有点晕...弱弱的问一句,能不能详细说一下步骤
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询