views:

75

answers:

3

I'd like to write a little class that adds a Day/Month box showing the date a SWF was published from Flash.

The company I work for regularly produces many, many SWFs and many versions of each, iterating over the course of months. A version-tracking system we've been using to communicate with our clients is a Day/Month date-box that gives the date the SWF was published. Up until now, we've been filling in the publish date by hand. If there's any way I can do this programatically with ActionScript that'd be fantastic.

Any insight? Basically, all I need is the call that gives me the publish date, or even.. anything about the circumstances under which a SWF was published that I could use to roll into some form of.. automated version identification, unique to this SWF.

So, can ActionScript tell when a SWF was published?

+1  A: 

I'm afraid you can't do it in Actionscript. Depending on how you build the swfs, there might be a couple of options. For instance, if you use the Flash IDE, you could use a JSFL script to publish the swf. This jsfl could replace a placeholder variable where you will store the publication date, and the publish the swf (haven't write a JSFL script in a long time but it shouldn't be too hard to get this working).

So, let's say you have a Version class:

public class Version {

    public var publicationDate:Date = new Date();

}

Your script should read the file where this class lives, find that line and replace it with the current date:

Something like this:

var curDate = new Date();
var dateLine = "public var publication:Date = new Date(" + curDate.getFullYear() + "," + curDate.getMonth() + "," + curDate.getDate() +");";
Juan Pablo Califano
That's certainly not a bad idea. I had thought that I might have to turn to JSFL to accomplish this. Unfortunately, I can't do that for the time being, but it's good to know it can be accomplished in that way.
spiralganglion
A: 

Not sure if this would work, but could you use an 'include' statement which calls in an externally generated .as file at compile time which has the (then) current date hard-coded into it? You'd need to have a script of some kind running on your server to update this file once a day to keep it current.

Richard Inglis
I suppose this could work, but it would be a little bit difficult for us to set up, as we're not running any servers. These SWFs are published by individual developers. I suppose I could hack together some sort of batch or something, but that'd be tricky. Thanks for the idea.
spiralganglion
A: 

Also you can read the date from the SWF bytecode with the awesome as3swf library. Check this out.

George Profenza
This looks promising. I will try it out and change the answer when I verify that it works. Thank you very much for this.
spiralganglion