当前位置:软件学习 > Flash >>

分享鼠标跟踪效果

var g = 2, st = 0, i, clearPoint = 200;
var points = new Array();
function flower() {
        for (i=0; i<Math.floor(2+Math.random()*4); i++) {
                var obj = attachMovie("flower", "flower"+points.length, points.length);
                points.push(new Array(obj, _xmouse, _ymouse, Math.floor(Math.random()*10-5), Math.floor(Math.random()*15-12), Math.floor(70+Math.random()*30)));
        }
}
function onEnterFrame() {
        trace(st+","+points.length);
        for (i=st; i<points.length; i++) {
                var tmp = points[i];
                if (tmp == null) {
                        if (i == st) {
                                st++;
                        }
                        continue;
                }
                if (tmp[5]<0) {
                        tmp[0].removeMovieClip();
                        points[i] = null;
                } else {
                        tmp[0]._alpha = tmp[5];
                        tmp[0]._x = tmp[1];
                        tmp[0]._y = tmp[2];
                        tmp[1] += tmp[3];
                        tmp[2] += tmp[4];
                        tmp[4] += g;
                        tmp[5] -= 5;
                }
        }
        if (st>clearPoint) {
                points.splice(0, st);
                st = 0;
        }
}
var obj = new Object();
obj.onMouseMove = function() {
        flower();
};
Mouse.addListener(obj);

补充:flash教程,As3.0
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,