2 Replies Latest reply on Aug 30, 2008 12:42 PM by JohnWalsh2011

    SWF movie recognising time of day.

      I'm making a flash swf file and wondered if there is any actionscript where it will recognise the time of day and 'if time of day =' ,etc. it will only play a certain frame. The purpose of this is that when people view the movie at night, I want the movie to be a night time scene, then when they view it in the day its a daytime scene.

        • 1. Re: SWF movie recognising time of day.
          logeye Level 1
          Might want to look up the Date class

          my_date.getUTCHours() : Number


          Ex from Flash7 Docs

          var my_date:Date = new Date();

          • 2. Re: SWF movie recognising time of day.
            JohnWalsh2011 Level 1
            Off the top of my head, you could use a setInterval function to check the time every 100 ms and then use a control statement to decide what frame to play.

            // ************ ROUGH IDEA ************ //
            var intervalID = setInterval(setTime, 100);

            function setTime():Void {
            var myDate:Date = new Date();

            // Pass the time to another function

            function chooseFrame(passTheTimeHere) {
            // Switch statement for each hour

            // if else statement for different time segments

            // ************ END OF ROUGH IDEA ************ //