新年了, 就来个简单的烟花效果吧 :)
点击浏览该文件
MovieClip.prototype.onFire = function(x, y) {
for (var i = 0; i<30; i++) {
var depth = this.getNextHighestDepth();
var fire = this.attachMovie("firework", "firework"+depth, depth);
var myColor = new Color(fire);
myColor.setRGB(_root.c[this.count]);
delete myColor;
fire._x = x;
fire._y= y;
fire._xscale = fire._yscale=25+random(30);
fire._rotation = random(10)+i*11;
}
this.count++;
if(this.count > _root.c.length-1) {
clearInterval(this.time);
delete this;
}
}
onMouseDown = function() { //滑鼠按下事件
var obj = this.createEmptyMovieClip("f"+this.getNextHighestDepth(), this.getNextHighestDepth());
obj.count = 0;
obj.onFire(_xmouse, _ymouse);
obj.time = setInterval(obj, "onFire", 1300, _xmouse, _ymouse);
}
var c = new Array(0x66FF00, 0xFF00CC, 0x3333FF, 0xFFFF00); //设定烟花颜色
源文件:
点击浏览该文件