Xml gallery thumbnail thing

i’m working on a flash xml gallery. But there is one thing i can’t figure out.

i like it very much when the thumbnails are not i 1 line but 5 next to each other and then down. So the 6th one must load underneath the first one. Is there an actionscript for or is too complex?

can someone give me an answer about it.