Get multiple objects from a phased class name in KineticJS

I am using the Kinetic.js JavaScript Kinetic.js for an HTML5 canvas. Here is the stage.get() method to get objects from the scene (canvas). I assigned id or class names to each object

if I get the object by id var obj = stage.get('#obj_id') , it works, but if you try to get several objects by the class name var objs = stage.get('.obj_class_name') , it returns an empty object []

How can I get some objects from the scene.

+6
source share
2 answers

well, you can just do .getChildren () to get all the children, and then iterate over the array with the loop and the condition to add the new array that you created.

+1
source

You can use the name attribute. It works like a class in HTML. Use the stage / layer find('.<name>') function to select all of your elements with the name <name> (a dot is needed).

0
source

All Articles