HELP! Empty nodes problem

HELP!

In a nutshell, I’m trying to create a dynamic text box in which text show up for one XML node but not for another, so I have some XML nodes that have info in them and others that don’t. This seems like it would be a realatively easy thing to do, but I’ve been working on figuring out how to do so for days with no avail.

I’m working on a template for my portfolio gallery at:
http://www.kristinemorical.com/new/test4.html

I’ve linked pdfs to just some of the images in my modified xml slideshow from the tutorial using the following code from this forum:

picture.onRelease = function() {
    if (link[p] != null) {
        getURL(link[p], "_blank");
    }
}; 

Now, I’m trying to display the text “Click on image below to view PDF” in a dynamic text box when there is a pdf linked to the image and have the dynamic text box display nothing when there is no pdf linked. Right now it displays the word “undefined” when there is a empty XML node or there is now pdf linked, whihc is not desireable.

Any help would be greatly appreciated. I need to get this solved before I can go on to finish the rest of my site.

I’ve attached a link to my CS4 flash file and my code below:

XML:


<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<images>
    <pic>
        <image>http://www.kristinemorical.com/design/print/unitedway/unitedway1.jpg</image>
        <caption>Poster/Brochure: Poster Side</caption>
        <thumbnail>http://www.kristinemorical.com/design/print/unitedway/thumbs/unitedway1.jpg</thumbnail>
        <link>http://www.kristinemorical.com/design/print/unitedway/UnitedWayPosterBroc26x26.pdf</link>
        <linkdes>Click on image below to view PDF</linkdes>
    </pic>
    <pic>
        <image>http://www.kristinemorical.com/design/print/unitedway/unitedway2.jpg</image>
        <caption>Poster/Brochure: Brochure Side</caption>
        <thumbnail>http://www.kristinemorical.com/design/print/unitedway/thumbs/unitedway2.jpg</thumbnail>
        <link>http://www.kristinemorical.com/design/print/unitedway/UnitedWayPosterBroc26x26.pdf</link>
        <linkdes>Click on image below to view PDF</linkdes>
    </pic>
    <pic>
        <image>http://www.kristinemorical.com/design/print/unitedway/unitedway3.jpg</image>
        <caption>Large Envelopes</caption>
        <thumbnail>http://www.kristinemorical.com/design/print/unitedway/thumbs/unitedway3.jpg</thumbnail>
        <link></link>
        <linkdes></linkdes>
    </pic>
    <pic>
        <image>http://www.kristinemorical.com/design/print/unitedway/unitedway4.jpg</image>
        <caption>#10 Envelopes</caption>
        <thumbnail>http://www.kristinemorical.com/design/print/unitedway/thumbs/unitedway4.jpg</thumbnail>
        <link></link>
        <linkdes>   </linkdes>
    </pic>
    <pic>
        <image>http://www.kristinemorical.com/design/print/unitedway/unitedway5.jpg</image>
        <caption>Website Concept</caption>
        <thumbnail>http://www.kristinemorical.com/design/print/unitedway/thumbs/unitedway5.jpg</thumbnail>
        <link></link>
        <linkdes></linkdes>
    </pic>
    <pic>
        <image>http://www.kristinemorical.com/design/print/unitedway/unitedway6.jpg</image>
        <caption>Website Graphics</caption>
        <thumbnail>http://www.kristinemorical.com/design/print/unitedway/thumbs/unitedway6.jpg</thumbnail>
        <link></link>
        <linkdes></linkdes>
    </pic>
     <pic>
        <image>http://www.kristinemorical.com/design/print/unitedway/unitedway7.jpg</image>
        <caption>Website Graphics</caption>
        <thumbnail>http://www.kristinemorical.com/design/print/unitedway/thumbs/unitedway7.jpg</thumbnail>
        <link></link>
        <linkdes></linkdes>
    </pic>
</images>

Actionscript (AS2):


function loadXML(loaded) {
    if (loaded) {
        xmlNode = this.firstChild;
        image = [];
        description = [];
        link = [];
        linkdes = [];
        thumbnails = [];
        total = xmlNode.childNodes.length;
        for (i=0; i<total; i++) {
            image* = xmlNode.childNodes*.childNodes[0].firstChild.nodeValue;
            description* = xmlNode.childNodes*.childNodes[1].firstChild.nodeValue;
            thumbnails* = xmlNode.childNodes*.childNodes[2].firstChild.nodeValue;
            link* = xmlNode.childNodes*.childNodes[3].firstChild.nodeValue;
            linkdes* = xmlNode.childNodes*.childNodes[4].firstChild.nodeValue;
            thumbnails_fn(i);

        }
        firstImage();
    } else {
        content = "file not loaded!";
    }
}
xmlData = new XML();
xmlData.ignoreWhite = true;
xmlData.onLoad = loadXML;
xmlData.load("http://www.kristinemorical.com/photo_galleries/photogallery_mxfolder/testgallery2_images.xml");
///////////////////////////////////// 
listen = new Object();
listen.onKeyDown = function() {
    if (Key.getCode() == Key.LEFT) {
        prevImage();
    } else if (Key.getCode() == Key.RIGHT) {
        nextImage();
    }
};
Key.addListener(listen);
previous_btn.onRelease = function() {
    prevImage();
};
next_btn.onRelease = function() {
    nextImage();
};
/////////////////////////////////////  
p = 0;
this.onEnterFrame = function() {
    filesize = picture.getBytesTotal();
    loaded = picture.getBytesLoaded();
    preloader._visible = true;
    if (loaded != filesize) {
        preloader.preload_bar._xscale = 100*loaded/filesize;
    } else {
        preloader._visible = false;
        if (picture._alpha<100) {
            picture._alpha += 10;
        }
    }
};

picture.onRelease = function() {
    if (link[p] != null) {
        getURL(link[p], "_blank");
    }

};

function nextImage() {
    if (p<(total-1)) {
        p++;
    } else {
        p = 0;
    }
    if (loaded == filesize) {
        picture._alpha = 0;
        picture.loadMovie(image[p],1);
        desc_txt.text = description[p];
        picture_num();
        pdf_des();
    }
}

function prevImage() {
    if (p>0) {
        p--;
    } else if (p == 0) {
        p = (total-1);
    }
    if (loaded == filesize) {
        picture._alpha = 0;
        picture.loadMovie(image[p],1);
        title_txt.text = heading[p];
        desc_txt.text = description[p];
        picture_num();
        pdf_des();
    }
}

function firstImage() {
    if (loaded == filesize) {
        picture._alpha = 0;
        picture.loadMovie(image[0],1);
        desc_txt.text = description[0];
        picture_num();
        pdf_des();
    }
}

function pdf_des() {
    
    if (linkdes_txt.text != undefined){
    linkdes_txt.text._visible = true;
    linkdes_txt.text = linkdes[p];
    } else {
    linkdes_txt.text._visible = false;
    }

}

function picture_num() {
    current_pos = p+1;
    pos_txt.text = current_pos+" / "+total;
}
function thumbNailScroller() {
    // thumbnail code! 
    this.createEmptyMovieClip("tscroller",1000);
    scroll_speed = 10;
    tscroller.onEnterFrame = function() {
        if ((_root._ymouse>=thumbnail_mc._y) && (_root._ymouse<=thumbnail_mc._y+thumbnail_mc._height)) {
            if ((_root._xmouse>=(hit_right._x-40)) && (thumbnail_mc.hitTest(hit_right))) {
                thumbnail_mc._x -= scroll_speed;
            } else if ((_root._xmouse<=(hit_left._x+40)) && (thumbnail_mc.hitTest(hit_left))) {
                thumbnail_mc._x += scroll_speed;
            }
        } else {
            delete tscroller.onEnterFrame;
        }
    };
}
function thumbnails_fn(k) {
    thumbnail_mc.createEmptyMovieClip("t"+k,thumbnail_mc.getNextHighestDepth());
    tlistener = new Object();
    tlistener.onLoadInit = function(target_mc) {
        target_mc._x = hit_left._x+(target_mc._width+10)*k;
        target_mc.pictureValue = k;
        target_mc.onRelease = function() {
            p = this.pictureValue-1;
            nextImage();
        };
        target_mc.onRollOver = function() {
            this._alpha = 50;
            thumbNailScroller();
        };
        target_mc.onRollOut = function() {
            this._alpha = 100;
        };
    };
    image_mcl = new MovieClipLoader();
    image_mcl.addListener(tlistener);
    image_mcl.loadClip(thumbnails[k],"thumbnail_mc.t"+k);
}