Wanted to know if it is possible to make a bool-variable in flash that is set to ‘false’ by default. It then checks if a file exists at a certain location, and if so, the bool-variable is set to ‘true’ ?
Well, LoadVars would check if that file exists, and if its not, then u could assign the textField something like “Error loading file”, or “TextFile Does’nt exist”.
dataHandler = new LoadVars();
dataHandler.onLoad = function(success) {
if (success) {
myTextBox.text = "File exists";//or u could assign the target variable, it should look like: (without the quotes) "myTextBox.text = this.ExternalVariable"
} else {
myTextBox.text = "File does'nt exist";
}
};
dataHandler.load("textfile.txt");
i don’t think you can’t check if a file exists with Actionscript only. h88’s method is clever, but it’s a workaround. If you really want to know if a file is in a directory, you’ll have to use PHP.
H88’s method works, but you have to wait for the file to load completely before Flash knows that the file exists. Somebody else asked this same question in the following thread:
I tried to answer the question there, but basically it involves the getBytesTotal() method, which is much quicker (I think) than loading the whole file.
I’m actually curious to see if that works. If anybody tries it out and it works, plz lemme know. Thanks.