0
在下面的代碼中,當我點擊circle
時,它的意思是使用txt.Text = "gffdfgdsgsdgsdg";
來更新txt
的文本屬性但是它不工作?你知道這是怎麼回事嗎?EaselJS使用onClick動態更新文本對象
function init() {
var canvas = document.getElementById('easel');
var stage = new createjs.Stage(canvas);
var circle = new createjs.Shape();
circle.graphics.beginFill("rgba(255,255,255,1)").drawCircle(40, 40, 40);
var shape = new createjs.Shape();
shape.graphics.s('red').ss(10, 'round', 'round').mt(50, 50).lt(250, 250).lt(50, 250).cp();
var shape2 = new createjs.Shape();
shape2.graphics.s('blue').ss(20, 'round', 'round').mt(200, 50).lt(250, 250).lt(50, 250).cp();
var txt = new createjs.Text("Hello CreateJS!", "15px Arial", "#FFF");
txt.y = 45;
shape.onClick = function (event) {
this.x -= 1;
};
shape2.onClick = function (event) {
this.x += 3;
};
circle.onClick = function (event) {
alert('fhdfhdfhg');
var s = this.x + ' y:' + this.y;
//txt.Text = "dfsdfs";
txt.Text = "gffdfgdsgsdgsdg";
};
stage.addChild(shape);
stage.addChild(shape2);
stage.addChild(circle);
stage.addChild(txt);
//Update stage will render next frame
createjs.Ticker.setFPS(15);
createjs.Ticker.addEventListener("tick", handleTick);
function handleTick() {
console.log('test');
circle.x += 2;
stage.update();
}
}