HTML5 Canvas Select Shapes by Name with KineticJS

To select shapes by name with KineticJS, we can use the get() method using the . selector.  The get() method returns an array of nodes that match the selector string.  The return array is a Kinetic.Collection array, which is basically a typical JavaScript array with a special each() method.  The each() method enables us to quickly iterate through every node in the array.

Instructions: press the "Activate Rectangles" button to select the rectangles by name and perform a transition on each.  You can also drag and drop the rectangles.

Open in new window

Code Editor

Modified on May 17th, 2013 by Eric Rowell
comments powered by Disqus