views:

201

answers:

1

Is there anyway in a flex application to figure out (in runtime) when the running swf was compiled?

I'd like to compare this with the latest file version of the swf on the server and detect if there's a newer version on the server and if so force the user to reload their browser to get the new version.

I need this to also work with swfs from the cache.

+6  A: 

What I normally do to make sure the user gets the latest version of a Flash file (because there is something weird with the caching of Flash content) is to use a serverside script to append the time the file was changed.

I've also been experimenting with setting variables in the swf, although that requires some command line trickery and won't really be practical if you're not using a build script.

Basically you append this to your mxmlc call:

-define+=BUILD::DATE,"2008-12-10"

Then the variable BUILD::DATE will be available during your build, so you can use that to set at static variable which you later read:

private static var COMPILEDATE:String = DATE;

(I wrote all this from memory so it might not be 100% correct syntaxwise)

grapefrukt
but is the value of DATE still need to be updated manually? Can the Flash IDE or Eclipse be configured to update it automatically?
Andy Li
unfortunately not, you'll have to do that yourself.
grapefrukt