Resize Images

Im creating an XML/FLash slideshow.

Some slides are larger than the space and some are way too small.

When linking from an XML file to images how do i determine the size of the images and then resize them accordingly so that it maximises the space available. For example a landscape image needs to be resized until it meets the maximum width allowed and the height would of course increase/decrease accordingly and of course the opposite for a portrait shot.

function updateSlide(newSlideNode) {
imagePath = newSlideNode.attributes.jpegURL;
slideText = newSlideNode.firstChild.nodeValue;
loadMovie(imagePath, targetClip);
targetClip._x=0;
targetClip._y=0;

so im looking for somethig to put at the end of this to resize targetClip appropriately. Please please please help me