一个小图标在小范围内浮来浮去的做法

      flash As 2005-9-1 16:59:00

将该小图标转换为MovieClip,定义实例名称。
然后设置MC的x,y坐标。
setProperty("实例名称"_x,x+Random(10)-4);
setProperty("实例名称",_y,y+Random(10)-4);


一堆这样的小图标放在一起用duplicateMovieClip复制刚刚做好的小图标。
并通过setProperty设置它们的位置。
---------------------------------------------------------------

实例名:a1,在parent桢写:
a1.onLoad = function() {
walking=false;
}
在a1第一桢写:
speed=30;//运动速度的反比,此数越大速度越慢
xjumpR=50;//x方向的活动范围
yjumpR=50;//y方向的活动范围
mindis=2;//判断运动到位的最小距离
initx=area1._x;
inity=area1._y;
if(!walking){
firstx=abc._x;
firsty=abc._y;
finalx=initx+(random(2*xjumpR)-xjumpR+1);
finaly=inity+(random(2*yjumpR)-yjumpR+1);
walking=true;
}
setProperty("abc",_x,abc._x+(finalx-abc._x)/speed);
//trace((finalx-firstx)/speed);
setProperty("abc",_y,abc._y+(finaly-abc._y)/speed);
if(math.abs(finalx-abc._x)<=mindis and math.abs(finaly-abc._y)<=mindis){
setProperty("abc",_x,finalx);
setProperty("abc",_y,finaly);
walking=false;
}
第二桢:gotoAndPlay(1)
标签集:TAGS:
回复Comments() 点击Count()
喜欢就顶一下

回复Comments

{commentauthor}
{commentauthor}
{commenttime}
{commentnum}
{commentcontent}
作者:
{commentrecontent}