Wednesday, April 13, 2011

how to force new version of .SWF flash file to be loaded by users?

I dont want to rename actual CODE (class), but how can I just rename .SWF file and in which tag in need to update this new name? I like to use e.g. build number in name.

E.g. myflash2.swf

From stackoverflow
  • One method is to add the build number as a querystring:

    myflash2.swf?build=1237
    

    But there is no easy way to do this without using build scripts, and that's assuming your using something a bit more advanced than the regular Flash authoring tool.

    I normally have a small php snippet that appends the last changed date for the file on the server to the end to be able to easily send new stuff to clients without having them clear their cache.

  • Like the previous answer, I did this successfully by using a bit of PHP in the wrapper that checked the modified date of the .swf. Here's the code...

    At the top of the wrapper:

    <?php 
    
    $appDate = filemtime("MyApp.swf");
    
     ?>
    

    Then when the src variable is built

    else if (hasRequestedVersion) {
    // if we've detected an acceptable version
    // embed the Flash Content SWF when all tests are passed
    AC_FL_RunContent(
      "src", "MyApp?version=<?= $appDate ?>",
      "width", "100%",
      "height", "100%",
      "align", "middle",
      "id", "MyApp",
    
  • you can also checksum the SWF file and append that to the filename

0 comments:

Post a Comment