87,989
社区成员
发帖
与我相关
我的任务
分享
function initCircles() {
circles = [];
for(var i=0; i<100; i++) {
var circle = new createjs.Shape();
var r = 7;
var x = window.innerWidth*Math.random();
var y = window.innerHeight*Math.random();
var color = colors[Math.floor(i%colors.length)];
var alpha = 0.2 + Math.random()*0.5;
circle.overcolor="red";
circle.alpha = alpha;
circle.radius = r;
circle.graphics.beginFill(color).drawCircle(0, 0, r);
circle.x = x;
circle.y = y;
circle.index = i;
circles.push(circle);
circle.movement = 'float';
circle.addEventListener("mouseover", function(event) {
circles[circle.index].graphics.clear().beginFill("#BD07D5").drawRect(0,0,50,60).endFill();
stage.update(event);
});
circle.addEventListener("mouseout", function(event) {
circles[circle.index].graphics.clear().beginFill("#BD07D5").drawCircle(0,0,r).endFill();
stage.update(event);
});
stage.addChild(circle);
}
}