dcsimg
A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: [CS3][As2] Error when loading in web browser??

  1. #1
    Member
    Join Date
    Jul 2007
    Posts
    32

    [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?

  2. #2
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    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

  3. #3
    Member
    Join Date
    Jul 2007
    Posts
    32
    Timer? why would i want that?

  4. #4
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    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

  5. #5
    Member
    Join Date
    Jul 2007
    Posts
    32
    The thing is that I want to avoid the browser returning an error when the file don't exist, using loadMovie (can be changed)

  6. #6
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    then use php

    gparis

  7. #7
    Member
    Join Date
    Jul 2007
    Posts
    32
    Ok then how should i use php (I will load this things dynamicly and there is probably hundreds of them).

  8. #8
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    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

  9. #9
    Member
    Join Date
    Jul 2007
    Posts
    32
    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); 


    ?>

  10. #10
    Member
    Join Date
    Jul 2007
    Posts
    32
    Ok um... just ignore the *s there was some error when posting.

  11. #11
    Senior Member
    Join Date
    Aug 2000
    Location
    Montréal
    Posts
    14,141
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center