Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get multiple objects from stage by class name in KineticJS

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

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

How I can get multiple objects from stage .

like image 234
Muhammad Usman Avatar asked Dec 23 '12 07:12

Muhammad Usman


1 Answers

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

like image 181
SoluableNonagon Avatar answered Sep 21 '22 17:09

SoluableNonagon