Skip to main content
Known Participant
December 10, 2007
Answered

getTimer

  • December 10, 2007
  • 3 replies
  • 431 views
I'm new to actionScript and I was trying to figure out how to use getTimer. My goal is to display my age in hours, minutes, or seconds. Or some combination of those.

I found this but I think it does not apply to actionScript 3.0

this.onEnterFrame = function() {
var time = new Date();
var hours = time.getHours();
var minutes = time.getMinutes();
var seconds = time.getSeconds();
}

How do I use getTimer in actionScript 3.0? I don't think that will be too hard but I am also unclear on how I would calculate my age based on the information I get from getTimer.

Any Suggestions?
This topic has been closed for replies.
Correct answer PushkinAl
Hi, here is an example for you:

3 replies

kglad
Community Expert
Community Expert
December 10, 2007
you'll probably want to use Math.floor() on those variables after ageInMs.
PushkinAlCorrect answer
Participating Frequently
December 10, 2007
Hi, here is an example for you:
Known Participant
December 11, 2007
Wow, that was easier than I thought it would be. Thank you for all your help.
kglad
Community Expert
Community Expert
December 10, 2007
create a date object with your birthdate, use the getTime() (NOT getTimer() ) method to obtain the number of milliseconds between your birth and 1970. then create another data object using the current date and use the getTime() method to determine the number of milliseconds between the current date and 1970. then subtract the current getTime() from your birth date getTime() and convert the resulting milliseconds (between the current date and your birthdate) to whatever format you want.