I am searching the web relentlessly for a Flash version of the PHP function file_exists. Basically, I have need to see if a file exists client side. Most of the techniques use LoadVars, which actually loads the complete object. Imagine trying to just see if a file exists, but having to load the 100MB file first?!?! Blegh.
Although horridly untested, I may have come up with a solution:
Actionscript: Check this before you wreck it.
fileExists = new Sound();
fileExists.loadSound('http://www.komodomedia.com/pathto/myfile.htm', true);
fileExists.setVolume(0);
fileExists.onLoad = function( success ){
if( success ){
trace("Loaded");
delete this;
}else{
trace("Failure");
}
}
The basic concept here is that Flash has this class called sound that is used to Stream MP3’s. By loading any file, turning off the sound, and telling it to stream it, we don’t have to load the whole file. Then, as soon as some data hits the Sound via the onLoad function, we know it exists. If not, then it doesn’t exist.
I’ve done minimal testing with this and it seems to work well.
Peace.

looks solid, will have to give her a go..
something unrelated again:
I always have to switch back to your website because it’s sooo beautiful!
Is there a tutorial or something like that for these sidebar tabs?
thank you in advance,
lamy :)
@lamy: No tutorial for the tabs yet, however, I’m using unobtrusive JavaScript to create XHTML/CSS that turns the display of one off and the other on using the
display:block & display:nonerules. Then, I usez-indexCSS to make tabs layer over eachother. Thats it!I was a bit curious to see if attempting to load a file that wasn’t a valid sound file would actually work as your code implies, but interestingly it appeared to crash my Flash Player. I was trying to load a .png file, and it would publish but would crash both the IDE player and the standalone player, and attempting to re-publish anything to the same file again would say “could not create .swf”. Very strange.
Last I checked, the Sound object continues to download even after you delete it. Maybe that has changed in Flash 8, but an easy way to test it is to test it online, and try to load 100 sounds, deleting the first 99 of them. Then see if the 100th sounds loads *extremely* slowly. If it does, this is an indication that the original 99 sounds are actually still downloading, although apparently into a black hole since the Sound object has been deleted. Quite annoying!