javascript - EaselJS update text object dynamically with onClick -


in code below when click on circle meant update text property of txt using txt.text = "gffdfgdsgsdgsdg"; wont work? know how todo this?

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 render next frame     createjs.ticker.setfps(15);     createjs.ticker.addeventlistener("tick", handletick);      function handletick() {          console.log('test');          circle.x += 2;          stage.update();     }   } 

you need update stage after update "text" property (maybe ticker doesn't work reason):

circle.onclick = function (event) {      txt.text = "gffdfgdsgsdgsdg";      stage.update();  }; 

pd: note "text" property lowercase.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -