*blog... kind of... *rss
Legal Age Verification with Actionscript
6 commentsHere it's a quick snippet I had to do for this site I'm working on...
I did a quick google search to see if there was a snippet for it already but didn't find anything so I though I would share it here. I though it was going to be a nightmare job but ended up quite simple:
I did a quick google search to see if there was a snippet for it already but didn't find anything so I though I would share it here. I though it was going to be a nightmare job but ended up quite simple:
var legalAge : int = 18; // or 21
var userDOB : Date = new Date(year,month-1,day);
var today : Date = new Date();
var diff : Date = new Date();
diff.setTime( today.getTime() - userDOB.getTime() );
var userAge : int = diff.getFullYear() - 1970;
if (userAge >= legalAge)
trace("lets get pissed!");
else
trace("go away!");
Very useful. Thanks!
February 10th 2009, joe
If users system shows wrong date, How this will work.
Thanks
Thanks
I agree.. perhaps just grab the date from the server instead a simple way would be to return mktime() from a php-script
ohhh I liked more the "porn" version :P
I think every time you visit a flash website you are agreeing a hidden term that your system clock is set on time ;) I used to have the clock out of time 10 years ago when it allowed me to use pirated programs for longer, but I think these days are over now. I don't see any reason why "normal" internet users would have the clock out of date. Specially these days that it auto syncs.
However, you guys are missing the point. This snippet wasn't for getting today's accurate Date(), this code was to compare the user's date of birthday with another Date(), however you get today's Date() is up to you.
@Peixinho: Hehe, but it said "click here" which was weird for a trace().
However, you guys are missing the point. This snippet wasn't for getting today's accurate Date(), this code was to compare the user's date of birthday with another Date(), however you get today's Date() is up to you.
@Peixinho: Hehe, but it said "click here" which was weird for a trace().
Yeah, I guess you are right. Those age disclaimers aren“t really there to actually stop someone to get in anyway. Just to put the legal blame on the actual user instead of the sender. There are however cases where a date comparison have to show the actual time diff, e.g countdown to the launch of a new site. Then I think a server query is the best way to go. And like you said. The only difference is how you require the Date().
Peace
Peace
*profile

traditional id: Ricardo Cabello Miguel
based in: London, UK
more: github, twitter, twitpic, soundcloud and flattr
*post nav
Synecdoche, New York & The Cinema Village
About the FWA Award Graphic Banner
ActionScript Tween Libraries
Understanding Flash Player Global Security Settings in just 20 steps
Succumbed to Twitter :S
Legal Age Verification with Actionscript
What.CD invites anyone?
Papervision3D Previewer 1.3
n0theen - 24/7 open source, netaudio stream
Sennheiser HD201
Following