-
[CS3][As2] Error when loading in web browser??
Hi.
In my swf I will dynamicly load a number of pictures into the swf.
But I want to see if the file exist first otherwise i will get a number of errors in the web browser when I try to load them. So how can I see if a file exist without getting an error in the browser if it don't?
-
Either you use PHP or you set up some timer in flash. Make a search in this forum to find methods to do either.
gparis
-
Timer? why would i want that?
-
you wait 1 or 2 secs for the server response, if the file doesn't load, you can assume it doesn't exist. It's a workaround in case you do not want to, or can't use PHP.
gparis
-
The thing is that I want to avoid the browser returning an error when the file don't exist, using loadMovie (can be changed)
-
-
Ok then how should i use php (I will load this things dynamicly and there is probably hundreds of them).
-
Prior to loading the assets, you call the php script via LoadVars. That php script reads the content of your directory and sends it back to the flash. Flash receives the list as a csv for example and transforms the comma separated values into an array in the onLoad of the LoadVars function. Then you can call your loading routine.
For help with php, or any other server side scripting languages, check the Scripting and Backend forum.
gparis
-
Thanks, I found this: http://board.flashkit.com/board/show...tent+directory
but of some reason i get an error (internal server error) when i try to execute the code (the php code), do you know why.
PHP Code:
<?php $dir = 'http://arongranberg.com'; $numfiles = 0;
if (is_dir($dir)) { ****if ($openDir = opendir($dir)) { ********while (false !== ($file = readdir($openDir))) { ************if ($file != '.' && $file != '..') { ****************if (is_file($dir . '/' . $file)) { ********************$f = explode('.', $file); ********************$ext = array_pop($f); ********************if ($ext == 'jpg') { ************************echo "&filename$numfiles=$file"; ************************++$numfiles; ********************} ****************} ************} ********} ****} ****closedir($openDir); }
?>
-
Ok um... just ignore the *s there was some error when posting.
-
or help with php, or any other server side scripting languages, check the Scripting and Backend forum.
you'll get more help there. this is the actionscript forum. In the Backend forum they can help you with server side languages.
gparis
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|