Solved

actionscript - detect server time and display relevant imagery

Posted on 2006-07-10
2
209 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

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 come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
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 live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…

730 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