KINETIC JS ON OFF (EVENT)

<html>
<body>
<div id=”container” width=”500″ height=”500″></div><button id=”ok”>Click me</button>
<script type=’text/javascript’ src=’Kinetic.js’></script>
<script>
var stage=new Kinetic.Stage({
container:’container’,
width:600,
height:500
});
var layer=new Kinetic.Layer();
var triangle=new Kinetic.RegularPolygon({
x:120,
y:120,
sides:3,
radius:80,
fill:’red’,
stroke:’black’,
strokeWidth:4
});
triangle.on(‘click’,function(){
var fill=this.getFill()==’red’ ?’#00D2FF’ : ‘yellow’;
this.setFill(fill);
layer.draw();
});

document.getElementById(“ok”).addEventListener(‘click’,function(){
triangle.off(‘click’);
alert(“eent is remove”);
},false);
layer.add(triangle);
stage.add(layer);
</script>
</body>
</html>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s