Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flex: Figure out when the running swf was compiled?

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.

like image 392
Niels Bosma Avatar asked Dec 10 '08 20:12

Niels Bosma


1 Answers

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)

like image 61
grapefrukt Avatar answered Oct 14 '22 07:10

grapefrukt