# Help with replacing "Undefined" text when there is no XML data

**URL:** <https://forum.kirupa.com/t/help-with-replacing-undefined-text-when-there-is-no-xml-data/304930>\
**Category:** flash\
**Created:** [February 16, 2010, 5:37pm UTC](https://forum.kirupa.com/t/help-with-replacing-undefined-text-when-there-is-no-xml-data/304930 "2010-02-16T17:37:26Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ozbozz](https://avatars.discourse-cdn.com/v4/letter/o/96bed5/32.png) [@Ozbozz](https://forum.kirupa.com/u/Ozbozz)\
**Post date:** [February 16, 2010, 5:37pm UTC](https://forum.kirupa.com/t/help-with-replacing-undefined-text-when-there-is-no-xml-data/304930/1 "2010-02-16T17:37:26Z")

</div>

Hi Guys,

Not sure if anyone could help, i’m a bit of a novice at actionscript and would appreciate some help.

A client has asked me to update the create for a flash widget, they have a problem with the widget displaying “Undefined” where there is no data being pulled in from the XML.

What they have asked me to do is write a bit of actionscript to display “Sorry, there is no offers at the moment” instead of it dipslaying “Undefined”.

I’m guessing it may go into the onLoad function? (see code below)

**Your help would be much appreciated!**

Cheers,  
Oz

\*\*  
ActionScript used to load XML:\*\*

//XML Class to process XML  
import spinnaker.core.xml.XMLExt

var offer\_array:Array; //holding Array  
var current\_offer:Object = new Object();  
//Loads XML  
var viking\_xml:XML = new XML();  
viking\_xml.ignoreWhite = true;  
viking\_xml.onLoad = function(success:Boolean) {  
trace("success: "+success);  
if(success) {  
offer\_array = processXML(viking\_xml.firstChild);  
current\_offer = getOffer(offer\_array, 1, 19)

```
    for(var prop in current_offer){
        trace("current_offer." + prop + "=" +current_offer[prop]);
        
    }
    
    
    gotoAndStop(2);
}

```

};  
viking\_xml.load(“viking.xml”); //URL update here

**ActionScript Used to populate text fields:**

function addOffer():Void{

```
trace(current_offer.date);

//Adds copy
header_txt.text = current_offer.header;
price_txt.text = current_offer.price;
body_txt.text = current_offer.body;
date_txt.text = current_offer.date;

//Sets button
delete btn.onRelease;
trace(current_offer.link)
btn.onRelease = function():Void{
    getURL(current_offer.link, "_blank");
}

offer_image.swapDepths(image_mc);
offer_image.removeMovieClip();
offer_image = addImage(current_offer.image);

trace(current_offer.section)
//Sets candle to correct point
for(var i:Number = 0; i &lt; candle_array.length; i++){
    if(i+1 == current_offer.section)
        candle_array*._visible = true;
    else
        candle_array*._visible = false;
        
    trace(candle_array* + ":" + candle_array*._visible);
}

```

}
