Checking If File Exists
What script could i use to check if a .txt file exists.
Adobe > ActionScript 1 and 2
Posted on: 02/21/2008 12:07:45 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Checking To See If A File Exists
I'm working on a system that will let me load an swf file while I'm within another swf file. I have it so it loads fine, but I'm trying to foolproof this. I don't have anything set up to deal with typos. How do I check and see if a file exists before Flash tries to load it?
DemonKilla
http://www.DemonKilla.com
Help- Checking If File Exists?
Hi all
Is there an equivalent to PHP's if(file_exists) command? That is, checking whether a text file exists or not.
Also, when Flash calls a text file with only the file specified (e.g. "file.txt"), does it look in the folder where the swf is stored, or in the folder where the current page is? I've always wondered that.
Checking If A File Exists
Ok, i need to check if a file exists in flash and flash only (as opposed to external files)
this is what i have so far, i got it from another website but it isn't very accurate.
Quote:
myVars = new LoadVars();
myVars.onLoad = function(success) {
if (success) {
_root.error.gotoAndStop("exists");
} else {
_root.check++;
}
};
myVars.Load("members/"+_root.name+".txt", myVars, "POST");
i need another way of determining if a file exists. I'm sorry, i can't explain it to well without showing you the .fla file, but i can't show u the .fla file either because it's something very private, if you need me to specify anything else anymore please post it, thanks for your help guys,
-rishi
[AS1] Checking A File Exists?
I've spent 2 nights at least searching the net for things like "actionscript 1 check file exists" and so on, and the best I find is people saying to check if a file exists, do this
Code:
fileExists=new LoadVars();
fileExits._parent=this;
fileExists.onLoad=function(success)
{
//success is true if the file exists, false if it doesnt
if(success)
{
//the file exists
var nm=this._parent.createEmptyMovieClip("swfHolder",1); //so create a movieclip
nm.loadMovie("myfile.swf"); //and load our .swf file into it
}
}
fileExists.load("myfile.swf") //initiate the test
Pretty much anything online saying how to check files uses this exact example.
The problem is while that may itself work, the action on success is fixed - I can't put all that in for every image load, and I can't make it into any kind of function - I've tried - the function will always return false when called because the image doesn't load until later.
The image doesn't finish loading until after the call is made and execution has carried on, so I see no way to know when you're checking if it exists without waiting around somehow for the image to load and then get a reply, but if it doesn't load then how would you know? Gah x_x
And I can't pass the function what to do when it loads etc because it will be varied. So yeah I've tried all sorts. The code I'm really trying to come up with would make something like this possible
Code:
If (DoesFileExist(filename)) { ShowImage(clip,filename); }
Else { clip.attachMovieClip("libitem","libitem",1); }
or maybe
Code:
var didItWork = ShowImage(clip,filename);
if (!didItWork) { clip.attachMovieClip("libitem","libitem",1); }
Do you see what I mean?
That way I can simply load images if they're there and if not I can load a library item that is a 'image not found' symbol. But frankly I can't for the life of me do it -_-
I'm severely tempted to use PHP to just check and return the result but I don't want to require PHP just for that and I think I'd have similar problems waiting around for the reply
Checking If A File Exists
Im writing a slideshow program and I get an error when I try to load an image that doesnt exist. I did a lot of searching and cant find a way to check if an image file exists or not. Anyone have experience with this?
Thanks
Checking If A File Exists
Hey all,
I was wondering if there is a simple way to check if a file of a certain type (specifically, FLV) exists within a folder, using AS3. What I want to do is something along these lines...
Code:
if(there is a .flv file in the folder specified){
//Do something
}
Any help would be much appreciated. Thanks in advance!
tbeanz
Checking If A File Exists
Just a short question ...
How would you check if a file on a server exists and if not, check XX Times l8er again til ya find it and then go ahead with the script ...
any suggestions???
thanx in advance
Checking If A File Exists
does anyone know why this code would work when i test in in flash mx 04, but when i export my movie clip it stops working.
this code attempts to load a variable from an external text file. it first checks to see if the file exists, if it can't find it, it moves up a directory then checks again. again, this works perfectly in flash but when i export it and test it on my server it stops working. it will still find the file stored in the same directory, but if i delete that file it will not move directories.
ActionScript Code:
var strFileName = "pagetitle.txt";
fileExists = new LoadVars();
fileExists._parent = this;
fileExists.onLoad = function(success) {
if (success) {
//trace("Success: " + strFileName);
_root.loadVariables(strFileName);
} else {
//trace("Adding dots!");
strFileName = "../"+strFileName;
//trace(strFileName);
this.load(strFileName);
}
};
fileExists.load(strFileName);
//load
Checking If A JPG File Exists In A Folder
Hi all,
I'm in a panic and would need help, else - I dunno know what I will do, change jobs
I have this structure:
>banner (folder) --> banner.swf
>content (folder)
-->school (folder) -->images(folder with images)
----->program (folder) -->images(folder with images)
--------->course(folder) -->images(folder with images)
I would like this functionality:
The banner.swf file loads the images in the images folder in this sequesnce.
If there is an image in the course level, load those images else,
if there is an image in the program level, load those images else,
if there is an image in the school level, load those images.
Here is the code that is currently attached to my swf file.
function loadImage(){
banners = 13.; //number of jpg
directory = "../../../media/Banner_images/"; //the folder that jpgs are kept
//load a random jpg and set its alpha to 0
loadMovie(directory + Math.ceil(Math.random()*banners) + ".jpg",_root.loader);
fade = 0;
setProperty(this.loader, _alpha, fade);
//fade in the jpg
this.onEnterFrame = function () {
fade = fade+2;
setProperty(this.loader, _alpha, fade);
if(fade==100){
//run pause function when jpg is fully visible
pauseImage();
}
}
}
loadImage();
function pauseImage(){
startPause = setInterval(endPause, 50000);
function endPause() {
//remove startPause
clearInterval(startPause);
//once pause is over fade out the image
fadeImage();
}
}
function fadeImage(){
this.onEnterFrame = function () {
fade = fade-2;
setProperty(this.loader, _alpha, fade);
if(fade==0){
loadImage();
}
}
}
So basically, I just want to make the directory variable to be dynamic and change depending on the circumstances of image availability.
Thank you so much, would really appreciate all your help.
Best regards,
Michael
Checking If An External Sound File Exists
Is there any way to check if an external sound file exists? I've searched the net and found stuff on checking if files exist using LoadVars. But it doesnt work for sound.
Thanks,
Brendan Smith
Checking If File Exists? Works Fine In IE
so, what Im trying to do is search for xml files that are labelled by number (1.xml,2.xml,3.xml etc) and stop at the highest one. as you can see Ive put this in a function that starts at 10 and decrements each time it loads, each time testing if the file exists (starting at 10.xml).
now this seems to work all well and good in Internet Explorer (and Flash!) but for some reason in Firefox it falls over.
anyone know what could be causing this? or any way I could resolve the situation.
any help would be greatly appreciated
Code:
var ticktock = 10;
function findAvail(ticktock){
myVars = new LoadVars();
_root["ticktock"]--;
myVars.onLoad = function(success){
if(success){
_root["found1"].text = "found";
//trace("File loaded ..." +_root["ticktock"]+ ".xml");
}else{
//trace("File not found!" +_root["ticktock"]+ ".xml");
findAvail(_root["ticktock"]);
}
}
//search for xml using counter
myVars.load(_root["ticktock"]+".xml");
}
findAvail(ticktock);
I've attached an example if you want to test yourself.
Checking If File Exists? Works Fine In IE
so, what Im trying to do is search for xml files that are labelled by number (1.xml,2.xml,3.xml etc) and stop at the highest one. as you can see Ive put this in a function that starts at 10 and decrements each time it loads, each time testing if the file exists (starting at 10.xml).
now this seems to work all well and good in Internet Explorer and Flash, but for some reason in Firefox it falls over (and possibly other browsers?).
anyone know what could be causing this? or any way I could resolve the situation.
any help would be greatly (greatly!) appreciated
Code:
var ticktock = 10;
function findAvail(ticktock){
myVars = new LoadVars();
_root["ticktock"]--;
myVars.onLoad = function(success){
if(success){
_root["found1"].text = "found";
//trace("File loaded ..." +_root["ticktock"]+ ".xml");
}else{
//trace("File not found!" +_root["ticktock"]+ ".xml");
findAvail(_root["ticktock"]);
}
}
//search for xml using counter
myVars.load(_root["ticktock"]+".xml");
}
findAvail(ticktock);
I've attached an example if you want to test yourself.
Checking If File Exists / Change Width & Height
Hi,
I'm trying to return the width of a dynamically placed image. I've created a holder, but for some reason when I do a trace(holder._width); it just returns 0. Here is the script I am using - it checks to see if a file exists then loads the next image when the user pushes the next_btn. If the file doen't exist, nothing happens. My problem now is changing the registration point and setting its size, but I can't seem to return the width of the movie clip. Perhaps it has something to do with the holder path. Thanks in advance for your help.
code:
var fileExists:LoadVars = new LoadVars();
fileExists._parent = this;
fileExists.onLoad = function(success){
if(success){
var slides:MovieClip = this._parent.createEmptyMovieClip("slides_mc",1);
var holder = this._parent.slides_mc.createEmptyMovieClip("holde r_mc",1);
holder.loadMovie(person + "/" + folder + "/" + "image" + imagenum + ".jpg");
holder._x = regpoint_mc._x;
holder._y = regpoint_mc._y;
trace (holder._width);
}else{
imagenum--;
}
}
fileExists.load(person + "/" + folder + "/" + "image" + imagenum + ".jpg");
next_btn.onRelease = function (){
imagenum++;
fileExists.load(person + "/" + folder + "/" + "image" + imagenum + ".jpg");
}
Checking To See If Variable Exists
this seems like the easiest thing in the world, but i'm having problems with checking to see if a variable exists... so i'll break down what i've already done to try to get to the heart of the matter.
here's the script that's not working:
var1="test";
if (var1) {
trace ("true");
}
why is this not working....?
Checking If Swf Exists In Directory
Say I load an swf from another to be placed on a higher level. If the file does'nt exist then nothing happens and the user is left wondering why.
Is it possible to check if the file exists,and if not post an error? Similar to a bad html link.
Checking If A Variable Exists
Hi folks,
I'm passing a query string into flash and sometimes the name value pair simply won't exist in the query string. I would like to check to see of the variable that flash is expecting is set or not.
how do you check to see if the value is set?
Cheers.
Mark
Checking If Array Exists
hi,
iwant somthing like this, but am unsure of how to tell if an array exists?
var kill = fighterlist.lenght
if (kill array has not been made then){
fighterlist=[]
fighterlist.push(kill+1)
}
else if? (if it has been made){
fighterlist.push(kill+1)
}
Checking To See If A Clip Exists
hey.
How do I check if something exists.
for instance
for (n=1; n<12; n++) {
if (_parent['text'+n] == true){
trace (n)
}
}
i don't know if i'm on the right track. Basically i need to nest a couple of 'for' statements inside other 'for' statements but i only want to the code to work if the intended clip actually exists. Can anyone help me with this.
Thanx a lot
Checking To See If A Movieclip Exists
I have a series of swfs that I am loading externally. Some swfs have a movie clip named 'DownloadMC'. I am trying to check if the movie clip exists, but I keep getting an error.
Code:
var theMC= MyLoadedMC.getChildAt(timesLoadCalled);// theMC is a loader object so use MovieClip(theMC.content)
trace('it exsists because here is the name: '+MovieClip(theMC.content).DownloadMC.name);//traces 'DownloadMC'
if(MovieClip(theMC.content).getChildByName('DownloadMC') != null){ var CallTopic:Sprite = new Sprite();
CallTopic.name = "CallTopic";
CallTopic.graphics.beginFill(0xFF2200,1);
CallTopic.graphics.drawRect(MovieClip(theMC.content).DownloadMC.x, MovieClip(theMC.content).DownloadMC.y, MovieClip(theMC.content).DownloadMC.width,MovieClip(theMC.content).DownloadMC.height);
MovieClip(theMC.content).addChild(CallTopic);
}
the code above gives me an error in the output:
Code:
TypeError: Error #1010: A term is undefined and has no properties.
at MethodInfo-464()
I hope this can be done,
thanks
Aubrey
Checking To See If A Movieclip Exists
I have a series of swfs that I am loading externally. Some have a movie clip named 'DownloadMC'. I am trying to check if the movie clip exists, but I keep getting an error.
Code:
var CallTopic:Sprite = new Sprite();
if(MovieClip(theMC.content).getChildByName('DownloadMC')){
CallTopic.name = "CallTopic";
CallTopic.graphics.beginFill(0xFF2200,1);
CallTopic.graphics.drawRect(MovieClip(theMC.content).DownloadMC.x, MovieClip(theMC.content).DownloadMC.y, MovieClip(theMC.content).DownloadMC.width,MovieClip(theMC.content).DownloadMC.height);
MovieClip(theMC.content).addChild(CallTopic);
}
the code above gives me an error in the output:
Code:
TypeError: Error #1010: A term is undefined and has no properties.
at MethodInfo-464()
not sure what the problem is?
aubrey
Checking If A Symbol Exists In The Library
Hi
My situation is thus: I have an XML file with entries, each of which contains a handle (linkage ID) to the movie clip that represents that entry onstage.
So I dynamically load these symbols in from the library accordingly. Only problem is, I need to be able to count how many of those entries are valid, that is, how many of the XML entries have handles that actually do correctly correspond to the names of the symbols in the library.
So right now in order to count the entries I am using the value of how many entries were in the XML file but this is wrong, I need a value of how many entries in the XML correspond correctly to a library symbol.
As it stands now, if all the names in the XML file match those in the .fla, all is good. Otherwise, issues. The thing is, I want this setup to be robust so the program takes responsibility and resolves issues if there are errors in the XML.
Now, the only way I can see to fixing this simply, is if there is a way to check if a symbol exists in the library -- without actually trying to load it.
That way I can count just those symbols from the XML file that also do exist in the library.
TIA,
-Nick
Checking Array To See If Variable Exists Before Adding
Hi all, this should be easy, but I can't get my head round it
What I want to do is check an array to see if the variable already exists in the array before adding it via push (if it does not already exist in the array).
Just a little example would be really helpful, cheers.
LoadVariables From File - Test If File Exists First
Thanx for previous help
But unfortunately I have another problem:
I'm reading a lot of variables (with loadVariables) from a textfile. It is important that the flashfile tests if the textfile exists before it starts reading the variables from the textfile. How can I do this?
ADDITIONAL REMARKS:
Why is the test important:
The variable eof is set to 0 in the very first frame.
The flashfile reads Varibales out of the textfile until eof=1;
The very last variable in the textfile is eof=1
When loadVariables reaches this point, reading stops.
So there will be an endless loop if the textfile is not there.
Our administrator says this is bad because of some caching reasons.
File Exists?
How can I know if a file exists before open it??????
How To Tell If A File Exists
Hello all,
How do you tell if a file that you want to load is there??
Say I put this action in the first frame of my movie:
loadVariablesNum(soAndso.txt, 0);
How can I tell if it couldn't find the path?
Thanks,
--FADE
File Exists?
Well, I am stumped. My total lack of programming skills is really beginning to show
Anyway, I have some text files (load1.txt, load2.txt, load3.txt, etc...), which reside in the same folder as the main SWF movie on my PC. I want to create a action in a stop frame in the movie to check if one of these files exists, then move to another frame in the movie an play.
(I know this isn't actual syntax, but I am only trying to show you what I mean)..
If "load3.txt" exists, goto and Play (3);
If "load2.txt" exists, goto and Play (2);
If "load1.txt" exists, goto and Play (1);
You get the idea. I know this can be done, I am just a dummy.
Any help would be greatly appreciated.
Regards,
Jason
File Exists?
Well, I am stumped. My total lack of programming skills is really beginning to show
Anyway, I have some text files (load1.txt, load2.txt, load3.txt, etc...), which reside in the same folder as the main SWF movie on my PC. I want to create a action in a stop frame in the movie to check if one of these files exists, then move to another frame in the movie an play.
(I know this isn't actual syntax, but I am only trying to show you what I mean)..
If "load3.txt" exists, goto and Play (3);
If "load2.txt" exists, goto and Play (2);
If "load1.txt" exists, goto and Play (1);
You get the idea. I know this can be done, I am just a dummy.
Any help would be greatly appreciated.
Regards,
Jason
Check If File Exists
Hi
How do you use actionscript to check if a file in the same folder exists? I want to check if a textfile exists. Thank you.
Check To See If A File Exists
My fla references an XML file. Is there some code that I can add to the beginning of my .fla to check to see if the xml file exists?
Thanks,
Nathan
Check If File Exists
im trying to create an easily update-able picture gallery.
in an images folder i will have:-
1.jpg
2.jpg
3.jpg
...etc
heres my problem
how can i get flash to check if (number).jpg exists
if i use something like this:
if (loadMovie (directory add "/images/"+myNumVariable+".jpg"))
then flash tries to load the image instead of returning a true/false value for the "if" statment.
any help would be much apreciated,
many thanks in advance
Owen.
Can AS Check To See If A File Exists?
Good Afternoon,
I am trying to write a program to dynamically display an image based upon some xml that is passed in, however (the kicker) if the jpg/png files doesn't exist I need it to replace the movie with another jpg loaded up, called file_not_found.jpg...
I've scrapped every attempt at doing this because everytime I try and get a getBytesTotal, I get 0.
Here is the simpliest way i can put it...
this.createEmptyMovieClip("mcPictureHolder", 1);
mcPictureHolder.loadMovie("image1.jpg", 1);
tbytes = mcPictureHolder.getBytesTotal();
trace(tbytes)
if (tbytes == 0){
mcPictureHolder.loadMovie("file_not_found.jpg", 1);
}
*** Editted - yes image1.jpg does exist***
Check If File Exists ?
OK, I'm creating thumbnail buttons and I need to make as many as there are jpg's.. they're in sequential order, so I need to do something like
if(fileexists){ goto next file and load this jpg}
Or any other suggestions?
Thanks!
Check If File Exists?
how do you Check if file exists?
There's a file located in the same directory as the swf. I need the swf to make sure the file exists befor it get loaded.
Check If File Exists?
how do you Check if file exists?
There's a file located in the same directory as the swf. I need the swf to make sure the file exists befor it gets loaded.
Check For File Exists?
Hey all,
I'm trying to create a photo gallery, but would like it to just create the correct number of thumbnail loaders w/o having to do anything through php or xml or similar. So I can control file names, so I'll loop like:
check thumbnails/pic1.jpg;
check thumbnails/pic2.jpg;
check thumbnails/pic3.jpg;
check fail, create 2 loader boxes etc etc...
What is the 'check' though?
Thanks,
Check To See If A File Exists.
I know what your thinking "A simple question with a simple answer." but wait there is a twist to this one. With conventional methods using loadVars you must actualy download the file first before knowing if it exists or not. In my circumstance however i mearly want to validate the files existance. If you know a way to do this it would be much apprecated.
How Do I Check If A File Exists In AS3?
I have an image URL being passed from FlashVars. It picks up the variable but I need to check if the file actually exists, and if it doesn't, set a variable to null.
I've tried a few things but none seem to work, any help would be much appreciated!
Thanks,
Richo
If File Exists, Then Play...
Hello all, thanks in advance for your help!
Imagine the following.
1.swf
2.swf
3.swf
4.swf
These are each separate movie files (duh!), random number of frames, each with different content.
I want to load each of these external files in-turn inside a 'master' swf file.
Now then - I won't always need to run ALL the files. I might just want to run 2.swf then 4.swf and leave out the others.
I'm fairly new to actionscript, have had some experience with ASP, but am currently working in PHP. I'm getting all my bloomin code confused, but I know EXACTLY what I want to do:
if file exists (1.swf) then {
count number of frames for 1.swf as frameno1
create mc = '1_mc'
this then needs to be ('frameno1') frames long
loadMovie("1.swf","1_mc");
}else{
move onto next bit of code
}
if file exists (2.swf) then {
count number of frames for 2.swf as frameno2
create mc = '2_mc'
this then needs to be ('frameno2') frames long
loadMovie("2.swf","2_mc");
}else{
move onto next bit of code
}
etc....
So, if the files exist, then play them sequentially. Otherwise skip.
Sounds easy - but it aint! (at least not for me).
Thanks again,
Rachael
File Exists Problem
I have some trouble with overwriteing previous streams i recorded. My app is simple i want to record a stream and then let the user view it. He can then record the stream again and view the new recording. My problem is that when a recording is done i copy it to another location (using virtual directory mapping) only when i check for the just created recording by doing the following:
var tmp = new File("streams/instancename/recording");
if ( tmp.exists){
//copy the file
}
else{
trace("recording not found";
}
it traces that the recording is not found. Has this something to do with the fact that the recording thas was written by FMS needs more time before the file system realizes it is there? Besides that i have the problem that when i overwrite an flv file an play it, the old recording is shown and not the new one. Has this something to do with caching because the old recording does not exist any more as a file? I tried several things but i am nog getting any further so any help would be appreciated...
Determining If A File Exists
Is there a way, using actionscript, of determining if a file exists within a directory on the web server? I’m using Flash MX Pro.
[sorry for the briefness, I'm assuming it'd better to get to the heart of the matter without rambling]
Check If File Exists
i'm trying to find a way to get flash to find if a file exists inside a folder, if so play it, if not cycle to the next possible file name and try again. so far i've used a try/catch statement and loadVars and an onLoad function statement but the first doesn't work and the load vars comes up with an infinate loop and flash terminates it. if anyone has any ideas i'd be VERY greatfull
thanks
ads
Determining If A File Exists
Is there a way, using actionscript, of determining if a file exists within a directory on the web server? I’m using Flash MX Pro.
[sorry for the briefness, I'm assuming it'd better to get to the heart of the matter without rambling]
Check If File Exists
Sigh
I´m buildning a dynamic slideshow (seem like everybody´s doing that nowadays). The jpgs are named like image1.jpg image2.jpg and further...
Now, how can I detect when there are no more imges, ie when the user is in the last one? I´ve tried several different approaches without satisfying results. Example (on the "holder-clip" wich are duplicated for each new jpg):
Code:
onClipEvent(data){
if(this._width > 0){
//do some stuff with the image
}else{
_root.error() //outputs an error message
}
}
If i try (this.getBytesTotal = "-1") it works in the flash-preview, but not on the server.
So, how can I find out if there is any more jpg:s to load or not?
Check If File Exists In As
Hello!
Probaby a simple problem but I can`t find a solution anywhere!
Sometimes I need to check if a file exists - FLfile.exists checks only URI locations but how check URLs?
Thanks in advance for any help :)
Check If File Exists
I am building a data driven menu. I want to load a thumbnail for each menu item, if a thumbnail pic exists. I can do this pretty easily with loadMovie. However, if the jpg does not exist, then it prints out out an error. How do I test to see if the jpg exists, before I try to load it with loadMovie? I want to do something like this:
if( exists(filename.jpg)) { loadMovie("filename.jpg", thumbnail);}
else { /* do something else since jpg does not exist */ }
Thanks!!!
Does Anyone Know How To Check To See If A File Exists On A Server?
Hello everyone!
I am in a bind. I need my flash app to check the existance of a file on my server that might or might not exist at the time (dynamically created and destroyed). I was hopeing I could catch an error true/false value returning from the loadVariable function if it failed to find the file or load anything, however it seems that function always returns a false value even if it does find a file.
Sooooooo
Anyone got any ideas? Well, short of actually writing a CGI script that checks if the file exists on the server and I just do a GET method to it expecting the proper response.
Thank you!
-Brian
|