1

我想展示一个Timer关于从 MySQL 获得的时间戳的 ActionScript 3.0 。

所以假设 MySQL (PHP) 返回一个字符串,就像$my_birthday="2013-05-22 12:30:45" 我从 ActionScript by a 得到的那样URLLoader,我想像这样显示计时器:

My age:
01 hours 01 minutes 42 seconds

我应该使用什么功能:

public function timerHandler(e:TimerEvent)
{
 log_textfield.text = String((new Date()).time) - my_birthday; // I need to convert the   Date().Time to unix timestamp I guess, and a function for time difference.
}
4

1 回答 1

0

这个答案有一个您可能想要使用的 TimeSpan 类。下面的代码应该可以完成获取 TimeSpan 所需的操作,您可以在其中获取需要显示的部分。我在这台电脑上没有 Flash 来测试,所以你的里程可能会有所不同:)

// new Date() is allergic to dashes, it needs slashes.
my_birthday = my_birthday.replace('-', '/');
var sinceBirthday = TimeSpan.fromDates(new Date(), new Date(my_birthday));
于 2013-05-22T09:50:37.823 回答