TypeError: object.width is not a function in kinectic.js file

104 Views Asked by At

When I am resize the shape "Kinetic.Rect" function. On that click event it shows the rect.width is not a function error.

for more clear here the image of the regarding task

enter image description here

As per image shows and below description, shape is rectangle. Now, I want to resize on the shape on the shape click event at that time it shows the "TypeError: rect.width is not a function" error.

Here is my jquery code for the add shaped and resize on the shaped click event.

function addRect()
{
     layer = new Kinetic.Layer();

     rect = new Kinetic.Rect({
      x: 239,
      y: 75,
      width: 100,
      height: 50,
      fill: 'green',
      stroke: 'black',
      strokeWidth: 4,
      draggable: true   
    });

    rect.on("click",function(){
      var _width = rect.width();
      var _height = rect.height();

      var width = _width + 10;
      var height = _height + 5;

      rect.setWidth(width);
      rect.setHeight(height);
      rect.draw();
    });

// add the shape to the layer
layer.add(rect);

// add the layer to the stage
stage.add(layer);

}
    //This click function is for create rectangle shape
$("#textsubmitShape").live("click",function(){  
    addRect();
});

And I am using the kinetic-v3.9.3.js and jquery.min.js file.

Advance In Thanks.

0

There are 0 best solutions below