A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: How to check to see if .swf file is present

  1. #1
    Member
    Join Date
    May 2001
    Posts
    69

    How to check to see if .swf file is present

    Hi,
    I'm loading up my movie, and when that movie has loaded, I want to check to see if another specific .swf is in the same directory.

    What's the easiest way to check to see if that .swf is there? I guess I could do a "If Getbytestotal < 1" to see if it's there, but thought there might be a better way of doing it.

    Maria

  2. #2
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749
    Can't be done with Flash on its own - the only way Flash can tell if a file is there, is to load it.

  3. #3
    Member
    Join Date
    May 2001
    Posts
    69
    Thanks.

    Any idea why the following isn't working?

    loadMovieNum("dc.swf", 2);
    // This checks to see that dc.swf is present.
    if (_level2.GetBytesTotal()<1) {
    _root.gotoandstop(25); // jumps to end frame if dc.swf not there
    }
    Last edited by mvmartin; 08-27-2003 at 08:24 PM.

  4. #4
    shorter than most, but not all findShorty's Avatar
    Join Date
    Apr 2002
    Location
    brisbane
    Posts
    239
    getBytesTotal is a method of Movieclip and therefore needs to be written like this:

    getBytesTotal()

    i still don't think the script will work though. it may work locally, but on a server, you need to make allowances for the delay in sending a request and receiving a 404 not found error.

  5. #5
    Denied ACCESSORIES
    Join Date
    Dec 2000
    Location
    Rio de Janeiro
    Posts
    208
    Originally posted by mvmartin
    Thanks.

    Any idea why the following isn't working?

    loadMovieNum("dc.swf", 2);
    // This checks to see that dc.swf is present.
    if (_level2.GetBytesTotal()<1) {
    _root.gotoandstop(25); // jumps to end frame if dc.swf not there
    }
    What you could do is use a serverside script and then have it look in the directory for .swf files and if any return send the info to flash. Don't know how comfortable you are with Scripting though.
    ..,,;:'""':;,,..ASTRO

  6. #6
    Senior Member FPChris's Avatar
    Join Date
    May 2003
    Location
    NJ
    Posts
    644
    What about something like this ?

    code:


    //frame 1
    var check = MyClip.getBytesTotal(); // size of empty container

    //frame 2
    MyClip.loadMovie(ClipName,ClipDepth);
    var count = 0;
    var MaxCountCheck = 50;

    //frame 3 - empty


    //frame 4

    if(count > MaxCountCheck){ gotoandPlay("Failed"); }

    if(MyClip.getBytesLoaded() <= check) {
    count++;
    gotoAndPlay(_currentframe-1); //loop back to 3
    }

    //normal preloader code here//




    If the clip bytes remain inactive for MaxCountCheck
    the file is either lagging or isn't there.
    MaxCountCheck would need to be large enough to 'know'
    it isn't just a server lag.

    Chris.
    Last edited by FPChris; 08-27-2003 at 11:15 PM.
    http://www.**********-dms.com

  7. #7
    Senior Member
    Join Date
    Aug 2002
    Location
    Dublin, Ireland
    Posts
    1,749
    The basic problem is the same, and no matter how you dress it up, a Flash only solution is going to be disappointing: simply, Flash doesn't have any capacity to do what you are looking for. Therefore, any function you do eventually come up with will at best be slow and cumbersome. It will also cause a lot of headaches with, for example, hogging bandwidth downloading files you don't need, long delays experienced by the user, and fundamentally unreliable working.

    If it were me, I would approach the problem from a different side, either:
    1. (as per Astro_sk) Write the two line server script needed to return true or false when asked to check for a specific filename.
    Or:
    2. Use an XML file-listing (generated at file upload time, or by a server script)

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