我試圖在mouseoveer事件發生時更新每個圓圈上方的圓圈和文本,但是我只成功更新圓圈,但不知道如何更新文本。EaselJS如何更新文本
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.color = color;
circle.alpha = alpha;
circle.radius = r;
circle.graphics.beginFill(color).drawCircle(0, 0, r);
circle.x = x;
circle.y = y;
var txt = new createjs.Text(i.toString(), "11px Arial", "#FFF");
txt.x = x - 4;
txt.y = y - 18;
var con = new createjs.Container();
con.addChild(circle, txt);
con.addEventListener("mouseover", function(event) {
event.target.graphics.clear().beginFill(event.target.color).drawCircle(0, 0, 15).endFill();
event.target.text = "dsfasd";
stage.update(event);
});
stage.addChild(con);
}
考慮使用圖形命令來更新您的形狀填充,而不是:直接訪問兒童,而不是直接訪問兒童:http://blog.createjs.com/new-command-approach-to-easeljs-graphics/ – Lanny