get child at
I was wondering if there's a way to get number of children in a particular view. For instance, I want to get the total number of children in a scroll view then animate fade out and then delete it. Below is the code I'm trying to achieve coming from an AS3 background. Also, the reason I assigned hide.i = x is because I don't know how to achieve a delegate in Ti. Therefore, it's hacked up that way.
var numChildren = scrollView.numChildren;
for (var x = 0; x < numChildren; x++) {
var anim = Titanium.UI.createAnimation();
hide.opacity = 0;
hide.duration = 150;
hide.delay = 75*x;
hide.id = x;
scrollView.getChildAt(x).animate(hide);
hide.addEventListener('complete', function(event) {
var child = scrollView.getChildAt(event.source.id);
scrollView.remove(child):
}
}
Thanks!
1 Answer
-
For the benefit of others going forward, here's one possible solution.
var elements = scrollView.getChildren(); for (var idx in elements){ //do something Ti.API.info(JSON.stringify(elements[idx]); }