I'm very new to Kinetic.js and I can't find a solution to my problem. I create a new kinetic.line here:
var shape = new Kinetic.Line({
color: area.colour
});
And I want to use the color attribute in an if loop:
stage.on('mouse down', function(evt) {
var shape = evt.targetNode;
if (shape.color == 'red') {
window.location.href = 'http://www.google.com';
}
});
This doesn't work, what do I need to do?
There is no color attribute. Use 'fill' instead. Then use 'mousedown' event instead of 'mouse down'.
var shape = new Kinetic.Line({
fill: area.colour
});
stage.on('mousedown', function(evt) {
var shape = evt.targetNode;
if (shape.getFill() === 'Red') {
window.location.href = 'http://www.google.com';
}
});
Take a look at the documentation http://kineticjs.com/docs/Kinetic.Line.html.