Solved

actionscript - detect server time and display relevant imagery

Posted on 2006-07-10
2
187 Views
Last Modified: 2008-03-10
Hi,

I'm working on a flash movie whose background image should change according to the time of day:

7am - 5pm - day time
5pm - 8pm - cloudy
8pm - 7am - evening

This is the actionscript function I have so far:

function getGTM(){
        // Create the date object and obtain the universal hour
        var tDate:Date = new Date();
        tH = tDate.getUTCHours();
       
        // Compare the hour and determine the image to display
        if((tH >= 7) && (tH <= 17)){
                cielo.gotoAndStop("day");
                luces.gotoAndStop(1);
                pMostrar = "Day";
        }else if((tH >= 17) && (tH <= 20)){
                cielo.gotoAndStop("afternoon");
                luces.gotoAndStop(1);
                pMostrar = "Afternoon";
        }else{
                cielo.gotoAndStop("evening");
                luces.gotoAndStop(2);
                pMostrar = "Evening";
        }
}
getGTM();


It's not working as planned. I'd greatly appreciate any insight.

Thanks,

Al
0
Comment
Question by:myrepublic
2 Comments
 
LVL 7

Accepted Solution

by:
muxxter earned 500 total points
ID: 17111264
Well first, I would fix the redundancy when comparing the hour to 17. More than one case is true when it's 5 o'clock. Unless that's what you want. :-)

Other than that, it looks sound. What does it not do that you'd like to have it do?

MuXx
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is a very simple example to help those of you who are still migrating from AS2 to AS3 understand the redesigned event model in AS3. In AS2.0, event functions (that is, the function to be performed when an event is fired) were stored as a pro…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.

910 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

15 Experts available now in Live!

Get 1:1 Help Now