When to use setChildren / or numchildern?

Okay this came to my attention on Depth swapping,
and reading some tutorials were cause my brains to go smooshie…

When and were is the best time. . to setChildren…

or an example of it?..

Should it go on the Main.as ?

Under its function… or load?..

anyone give me a good thought on this… or example…
Cause i seem to be failing when ever i try to use it…

Does it need like an object container?