kineticjs - How do I create a button that loops through all the line variables making one visible at a time? -
how create button loops through line variables making 1 visible @ time?
i'm using kinetic javascript, want make button loops through line variables , every time click button turns next lines visiblity "true" , previous lines visibilty "false"
here code far: http://jsfiddle.net/nxt2l/4/
<body> <div id="container"></div> <div id="buttons"> <button id="show"> show </button> <button id="hide"> hide </button> <button id="reroute"> reroute </button> </div> <div id="container"></div> <script src="kineticjs.js"></script> <script> var stage = new kinetic.stage({ container: 'container', width: 1700, height: 1100 }); //creates our layer put on stage //note have building map layer , simply-- //--put these muiltiple layers ontop of each other. var layer = new kinetic.layer(); <!--room 202--> var line202n = new kinetic.shape({ drawfunc: function(canvas) { var context = canvas.getcontext(); context.beginpath(); context.moveto(454, 338); context.lineto(440, 351); context.lineto(533, 449); context.lineto(565, 449); context.lineto(635, 449); context.lineto(635, 368); context.lineto(591, 368); context.lineto(591, 289); canvas.fillstroke(this); }, stroke: 'blue', strokewidth: 6, visible: false }); layer.add(line202n); var line202s = new kinetic.shape({ drawfunc: function(canvas) { var context = canvas.getcontext(); context.beginpath(); context.moveto(454, 338); context.lineto(440, 351); context.lineto(533, 449); context.lineto(565, 449); context.lineto(635, 449); context.lineto(1432, 449); context.lineto(1432, 532); canvas.fillstroke(this); }, stroke: 'blue', strokewidth: 6, visible: false }); layer.add(line202s); //add layer stage stage.add(layer); // add button event bindings document.getelementbyid('show').addeventlistener('click', function() { line202n.show(); layer.draw(); }, false); document.getelementbyid('hide').addeventlistener('click', function() { line202n.hide(); layer.draw(); }, false); document.getelementbyid('reroute').addeventlistener('click', function() { line202n.hide(); layer.draw(); }, false); </script> </body>
Comments
Post a Comment