javascript - kinetic js - how do I modify attributes dynamically (onmouseover) -


i have following code, position doesn't vary mouseover - missing?

function drawoverlay() {     var stage = new kinetic.stage({container: 'overlay'});     var layer = new kinetic.layer();      var rect = new kinetic.rect({         x: 239, y: 75,         width: 100, height: 50,         fill: 'green', stroke: 'black', strokewidth: 4     });     rect.on('mouseover', function(e) {rect.setposition({x: 50, y: 5 0});});      layer.add(rect);     stage.add(layer); } 

two problems here:

  1. your y value has space in it: "5 0" vs. "50", causes javascript parsing error.
  2. you need redraw layer after changing position of node.

so try this:

rect.on('mouseover', function(e) {     rect.setposition({x: 50, y: 50});      layer.draw();  }); 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -