Solved

date/time comparison

Posted on 2007-03-28
2
202 Views
Last Modified: 2008-02-01
Hello.  I have a situation in flash 8 where i need my movie to show different things based on the time of day it is.  like from 12 AM to 3:59:59 PM i need it to show some things and from 4 PM to 11:59:59 PM i need it to show other things.  Can someone provide some AS that will get something like this done?  i realize it's based off of the users system time.  i'm not really concerned about the year/month/day.  just the hours, minutes and seconds of whatever day.

thanks!
0
Comment
Question by:linuxrox
2 Comments
 
LVL 2

Accepted Solution

by:
khoama earned 250 total points
ID: 18809199
var dDate:Date =new Date();

//get the current Date
dDate.getDate();

// 0 <= hh <=23
hh=dDate.getHours();

// 0 <= mm <=60
mm=dDate.getMinutes()

// 0 <= ss <=60
ss=dDate.getSeconds();

//do smthing here the time here
0
 
LVL 3

Assisted Solution

by:ieciep
ieciep earned 250 total points
ID: 18815181
the following code shows how you can compare time.

Hours value ranges from 0 - 23. Lemme know if you need the source file.

code info:
-----------
timeDisp is a movie clip symbol instance.

code:
------

var myDate:Date =new Date();
date=myDate.getDate();
hours=myDate.getHours();
mins=myDate.getMinutes();
secs=myDate.getSeconds();

if(hours>=6&&hours<16)//day
{
      timeDisp.gotoAndStop(1);
}
else if(hours>=16&&hours<20)//evening
{
      timeDisp.gotoAndStop(2);
}
else if(hours>=20&&hours<6)//night
{
      timeDisp.gotoAndStop(3);
}

Regards,
Riz
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

In my long career of working as an actionscript developer, I had spent sleepless night often working hard to solve some small problems which actually took a lot of my development time; later found out the solutions to be a line or two. Here are s…
While working over numerous projects I often had the requirement for doing a screen capture in AS3.0. Unfortunately I found no "ready made" solutions in google search that suited my requirements. But I did come across some great resources which help…
The goal of the tutorial is to teach the user how to how to record live broadcast.
The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now