View Full Version : I want to find an object in the display list?
soggybag
03-29-2008, 06:30 AM
Is there an easy way to find an object in the display list without looping and looking at each object?
amarghosh
03-29-2008, 06:48 AM
basically u got to have a reference to it in a variable (or an array).
otherwise, getChildByName is an option but it will fail if u have multiple children with same name (yes, u can have multiple children with same name to a DisplayObjectContainer -- and flash wouldn't complain -- kind of a bug, huh?) and hence not advisable. when i tested it, it always returned the child at lowest index when there were multiple children with same name.
if u want the last child u added use getChindAt(numChildren - 1);
if u just wanna check if something has been added as child to an object, use DisplayObjectContainer's contains() method;
soggybag
03-30-2008, 05:50 AM
Thanks, I have a reference to the clip in question. contains() is a great method to know. Turns out the best solution I found was:
clip.parent == host
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.