Xml orientation (my huge problem)

Merry Christmas & Happy New Year!
I’ve been making a Frankenstein kind of script (cutting and pasting pieces of code I find that works) without actually knowing what I’m doing but my main problem is this:

I have an xml gallery with both landscape and portrait photos. What is meant to happen is when the next button is pressed a movie clip of the transition is attached depending on whether the next photo in the xml gallery is a landscape or a portrait one (and maybe even center the the photo). I have a script loading the movie clip on the button and the script for the xml inside a gallery movie clip as well as some script inside the transition movie clips.

This forum has been very helpful suggesting that the xml images should be preloaded, or writing the orientation as a description inside the xml and then parsing it, and other things I do not quite understand how to do. Is there anyone patient enough to explain slowly and loudly how (and if) I can manage the above?