# Setting the state of a movieclip based on hours and minutes

**URL:** <https://forum.kirupa.com/t/setting-the-state-of-a-movieclip-based-on-hours-and-minutes/331237>\
**Category:** Uncategorized\
**Created:** [June 18, 2013, 10:52pm UTC](https://forum.kirupa.com/t/setting-the-state-of-a-movieclip-based-on-hours-and-minutes/331237 "2013-06-18T22:52:05Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![djjulia](https://avatars.discourse-cdn.com/v4/letter/d/779978/32.png) [@djjulia](https://forum.kirupa.com/u/djjulia)\
**Post date:** [June 18, 2013, 10:52pm UTC](https://forum.kirupa.com/t/setting-the-state-of-a-movieclip-based-on-hours-and-minutes/331237/1 "2013-06-18T22:52:05Z")

</div>

Hi there. I’m trying to have a movieclip move to a certain frame when it’s 2:30 during the day. Seems straight forward enough but not getting the results I want. I have tried several different methods. Here are the 3 different methods I’ve tried so far:

```auto

function getGameTime():void {
var my_date:Date = new Date();
var currentHour:Number = my_date.getHours() + my_date.getMinutes();
    if (currentHour < 14) {
        setTime();
    trace("game is later");
    }
    else if (currentHour > 14) {
        changeTime();
    trace("game time!");
    }
}

function setTime():void{
    matchup_mc.gotoAndStop(1);
    trace("game is later");
}

function changeTime():void{
    matchup_mc.gotoAndStop(15);
    trace("game time");
}

```

^that one thinks it’s always game time, plus I’m not sure how to pass the minutes variable.

```auto

var eventDate:Date = new Date();
 eventDate.setHours(14, 30);
 var now:Date = new Date();

 var delay:Number = eventDate.time - now.time;

 if( delay > 0 )//if we haven't yet passed 14:30
 {
   var timer:Timer = new Timer(delay , 1);
   timer.addEventListener(TimerEvent.TIMER, changeTime );
   timer.start();
   
 }

function changeTime(e:TimerEvent):void{
    matchup_mc.gotoAndStop(15);
    trace("hi I'm working");
}

```

^this one isn’t doing anything

Any help/clarity here would be greatly appreciated! Thank you!
