I have to load a text file.
First I want to detect if the file exists or not, so I use “if (rawTxt == undefined)”.
Now, if the file exists and contains data, the condition n°2 is met…it’s OK!
But now, if the file exists BUT is empty it doesn’t meet the condition n°2…why?
It’s not “undefined” neither “not undefined” since any trace action accours.
In other words, how can I check that a text file exists…AND that it’s empty or not
(so that I can add a branch if that condition is met?)
Try by yourself with an empty text file named “Favorites.ini”.
Thanks very much!
var loadFavorite = new LoadVars();
loadFavorite.onData = function(rawTxt:String) {
if (rawTxt == undefined) {
trace("It's undefined");
} else {
trace("It's OK");
}
};
loadFavorite.load("Favorites.ini");
same behavior with an onLoad function
var loadFavorite = new LoadVars();
loadFavorite.onLoad = function(success:Boolean) {
if (success) {
trace("onLoad success")
} else {
trace("onLoad success")
}
};
loadFavorite.load("Favorites.ini");