开发者

Is there an equivalent to __DATE__ in AS3? [duplicate]

This question already has an answer here: Flex: Figure out when the running swf was compiled? (1 answer) Closed 3 years ago.

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 hopi开发者_JS百科ng there was something built in.


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);
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜