I hope I am clear enough.
My data set is populated I have
comment:CommentVO;
comment.replies=[comment:CommentVO,comment:CommentVO,comment:CommentVO];
_comments:Array = [comment:CommentVO,comment:CommentVO,comment:CommentVO]
I’ve correctly populated my _comments Array and the replies array in my CommentVO Obj.
This works
for each (var comment : CommentVO in _comments) {
trace("TOP COMMENT" + comment.raw_message);
for each (var comment : CommentVO in comment.replies){
trace("1st DEPTH COMMENT REPLY " + comment.raw_message);
for each (var comment : CommentVO in comment.replies){
trace("2nd DEPTH COMMENT REPLY " + comment.raw_message );
for each (var comment : CommentVO in comment.replies){
trace("3rd DEPTH COMMENT REPLY " + comment.raw_message);
}
}
}
}
But I knew that the comment replies depth was 3 levels down.
How can i make that loop check to see if comment.replies array has content and run the loop?
It might look something like this but this is not correct.
var i:int=0;
for each (var comment : CommentVO in _comments) {
trace("TOP COMMENT" + comment.raw_message );
for each (var comment : CommentVO in comment.replies) {
trace( i + "DEPTH COMMENT REPLY " + comment.raw_message );
if(comment.replies.length >1){
i++;
}
}
}
I hope I am clear enough….I’ve been banging my head with this.
Thanks.
Here is the answer for anyone who needs it!!! and trust me you will if your data tree is dynamically generated without you knowing how deep the child to parent relationship will be.