javascript - Button click event wont fire after adding tween.js -


when add line of code tween display box click event not fire anymore. no errors in console. how fix issue? did wrong?

 createjs.tween.get(directionsbox, { loop: false }).to({ x:800, y: 650 }, 4000) 

full code

  var directionsbox = new createjs.container();                 displaybox = new createjs.shape();                 displaybox.graphics.beginfill("#d8d8d8").drawroundrect(0, 0, 800, 570, 2);                 displaybox.name = "directionsbox";                 displaybox.x = -800;                 displaybox.y = -650;                  var label = new createjs.text("\congratulations!  \n \nyou have completed 3 levels." + "\n \nyour score: " + totalscoresfromalllevels + "\n \nyour sccore submited arcade. \n\n\nplay again? click here.", "bold 20px arial", "#000");                 label.textalign = "left";                 label.linewidth = 540;                 label.y = displaybox.y + 5;                 label.x = displaybox.x + 10                  directionsbox.addchild(displaybox, label);                 self.stage.addchild(directionsbox);                 createjs.tween.get(directionsbox, { loop: false }).to({ x:800, y: 650 }, 4000)                  var helper = new createjs.buttonhelper(displaybox, "out", "over", "down", false, displaybox, "hit");                 helper.y = displaybox.y;                 helper.x = displaybox.x + 275                 displaybox.addeventlistener("click", handleclick);                 function handleclick(event) {                     console.log("clicking it");                     createjs.sound.play("click");                     self.stage.removechild(directionsbox);                     visitedupdatescorefunction = false;                     incrimentlevels();                     //initializegame();                     self.stage.removeallchildren();                     gamedata.terms = shuffle(gamedata.terms);                     gamehasended = true;                     addbackground();                     initializegame();                 } 

similar earlier issue reported, due hitarea. if recall, hitarea positioned based relative target. example, if draw circle @ [0,0], , move [0,100], hitarea should {x=0, y=0}. if offset hitarea well, it's x/y added target's position.

because tweening position of displaybox, , also using hitarea, when change x/y, hitarea added position.

  • x=0, y=0: hitarea draws @ [0,0]
  • x=100, y=0: hitarea draws @ [200,0]
  • x=200, y=100: hitarea draws @ [400, 200]

you can solve using null hitarea (it use itself), or cloning displaybox, , setting x , y 0.

here your demo, null hitarea. added cursor can see hitarea is.

here simplified demo. can rollover area lower right of circle see hitarea is.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -