all groups > flash actionscript > march 2005 >
You're in the

flash actionscript

group:

Conditionals


Conditionals vlb1176
3/18/2005 10:02:11 PM
flash actionscript:
Can anyone help me with the AS below?

What I?m trying to do is load an XML file into Flash with the date
concatenated using the date object in AS. I.e. 2005_03_18_somefile.xml so that
I can have multiple files that are five days or more in advanced without having
to update the same file everyday. And if the file doesn?t exist I?d like flash
to go thru the conditinal and find the backup XML file if it can't find the
proper date just in case I or one of my co-workers forgets to load the right
XML file.

The conditionals I have below are not working?. What am I doing wrong?


// initialize date variables
today_date = new Date();
monthNum = today_date.getMonth()+1;
dateNum = today_date.getDate();
yearNum = today_date.getFullYear();
fullDate = yearNum+"_"+monthNum+"_"+dateNum;

// initialize XML file
fileXML = fullDate + "_somefile.xml";

// initialize back up XML file
backupXML = "backup.xml";

// load XML file
my_xml = new XML();
my_xml.ignoreWhite = true;
my_xml.onLoad = parse;

if (fileXML == undefined) {
my_xml.load(backupXML);
}else{
my_xml.load(fileXML);
}


Thanks
vlb1176
Re: Conditionals foxchick
3/18/2005 10:39:13 PM
Your "if" statement is checking to see if the VARIABLE "fileXML" is defined,
which it is.

You need to see if the CONTENTS of "fileXML" exists...you need some sort of
"file exists" function...

I'm not sure how it works, but I found "fl.fileExists" in the help file, you
might try that...?
Re: Conditionals vlb1176
3/18/2005 11:27:47 PM
Thanks foxchick,

I will look into that!

Re: Conditionals abeall
3/19/2005 12:36:27 AM
you could always use the (success) param of the onLoad method: // load XML
file my_xml = new XML(); XML.prototype.ignoreWhite = true; my_xml.onLoad =
function(success){ if (success) { parse(); }else{ my_xml.load(backupXML);
my_xml.onLoad = parse; } }
AddThis Social Bookmark Button