views:

47

answers:

2

I'm looking for an equivalent to C/C++'s __TIME__ and __DATE__ compile-time constants in AS3. I want to be able to bake in when the swf was built.

I can write a build script or JSFL to update a constant somewhere, but I was hoping there was something built in.

A: 

It is just for both __DATE__ and __TIME__

new Date();

See this example below for how it might be used. You can find the documentation here.

/**
 * Called by the parent container when the display is being drawn.
 */
public override function draw():void
{
    // stores the current date and time in an instance variable
    currentTime = new Date();
    showTime(currentTime);
}

/**
 * Displays the given Date/Time in that good old analog clock style.
 */
public function showTime(time:Date):void 
{
    // gets the time values
    var seconds:uint = time.getSeconds();
    var minutes:uint = time.getMinutes();
    var hours:uint = time.getHours();

    // multiplies by 6 to get degrees
    this.secondHand.rotation = 180 + (seconds * 6);
    this.minuteHand.rotation = 180 + (minutes * 6);

    // Multiply by 30 to get basic degrees, then
    // add up to 29.5 degrees (59 * 0.5)
    // to account for the minutes.
    this.hourHand.rotation = 180 + (hours * 30) + (minutes * 0.5);
}
Nick Berardi
Sorry I meant __DATE__ and __TIME__ from the C/C++ world. Compile time constants, not runtime. I'll update the question.
Scott Bilas
+2  A: 

I believe this is what you are looking for:

http://stackoverflow.com/questions/357522/flex-figure-out-when-the-running-swf-was-compiled

clownbaby
Yeah, that's effectively the build script solution I was hoping to avoid (we're doing straight Flash via the IDE, not Flex). Still, I think it's about as close as I'm going to get.
Scott Bilas