Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detect if file exists before using LoadMovie

Status
Not open for further replies.

LittleHavoc

IS-IT--Management
Nov 28, 2001
56
GB
How can I detect :cool: if a .swf file exists before I load it.

I want to load a default movie if this occurs, similar to the <IMAGE NOT AVAILABLE> picture you see on some sites.
 
So? Decided to register after your yesterday's posting spree! LOL

What do you mean exactly? If your loading one of your movies, you should know if it exists or not!

Regards,
wink4.gif
ldnewbie
 
Well I know I did post a few, but it was the first time I used the site.

I am developing a generic quiz program that reads the questions from a text file. Inside the text file you can specify the .swf file that will be loaded as the background and foreground.

Layer 3 - foreground
Layer 2 - QUIZ
Layer 1 - background

So a Plants quiz has map of world background with planets and comets moving across the front.

If someone else is creating the quizzes and mistypes the filename or it doesn't exist(needs uploading), I want to play the default movie background.

I need to know if the file exists, perhaps through java. Unfortunately don't know any java, so would prefer to keep to Flash. Wondered if there was any way to detect errors, such as FAILED TO LOAD TEXT/MOVIE,FILE DOES NOT EXIST.
 
What you need to do is have a constant to reference to in your external file then you can run a simple if script :

1st frame :

Code:
var constant = &quot;&quot;;
loadVariablesNum (&quot;file.txt&quot;, 0);

second frame :

Code:
if (constant == &quot;&quot;) {
    msg = &quot;File not found!&quot;;
} else {
    msg = &quot;File loaded successfully!&quot;;
}code][/color]

Heres a demo :

[URL unfurl="true"]www.icuk.co.uk/clients/bbd/txtload.swf[/URL]
[URL unfurl="true"]www.icuk.co.uk/clients/bbd/txtload.fla[/URL]
[URL unfurl="true"]www.icuk.co.uk/clients/bbd/txtload.txt[/URL]

note. I gave the loadvariablesnum() a couple of frames to load the file Regards

Big Dave

davidbyng@hotmail.com


** If I am wrong I am sorry, but i'm only trying to help!! **
 
Sorry but I already using this to detect for omitted entries.

What I am trying to do is detect if the file exists, not if the name is blank. I can load a named movie into Flash if the movies no longer exist on the server.

File list on server:-
movie.swf
movie.html
movie_list.txt
background.swf
default_background.swf

Code:
movie=&quot;mybackground.swf&quot;;
background_level=2;

loadmovienum(movie,background_level);

FLASH
Oh! mybackground.swf doesn't exist,
nevermind I'll load in default_background.swf

I know there are some work arounds, but I want to make it as functional as possible. To make it available for Text, Movies, Graphics, Sounds etc...

Oh! mysound.mp3 doesn't exist,
nevermind I'll load in default_sound.mp3
Oh! mysound.wav doesn't exist
nevermind I'll load in default_mysound.wav
Oh! mymovie_list.swf doesn't exist,
nevermind I'll load in default_movie_list.txt
etc....


I could use PHP - int file_exists(string filename);
but I want to make it multiplatform and I know of one person that wants a copy that doesn't have any server side functionality just web space.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top