# Add time to countdown through item

**URL:** <https://forum.kirupa.com/t/add-time-to-countdown-through-item/256007>\
**Category:** programming\
**Created:** [March 29, 2008, 4:47am UTC](https://forum.kirupa.com/t/add-time-to-countdown-through-item/256007 "2008-03-29T04:47:07Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![thejoeknows\_com](https://avatars.discourse-cdn.com/v4/letter/t/5daacb/32.png) [@thejoeknows\_com](https://forum.kirupa.com/u/thejoeknows_com)\
**Post date:** [March 29, 2008, 4:47am UTC](https://forum.kirupa.com/t/add-time-to-countdown-through-item/256007/1 "2008-03-29T04:47:07Z")

</div>

I added a timer to my tile based game (based off tony Pa AS1 tutorials

the timer is as follows:

ACTIONSCRIPT:

```auto

start_time = getTimer();
countdown = 180000;
onEnterFrame = function () {
    elapsed_time = getTimer()-start_time;
    _root.count.text = time_to_string(elapsed_time);
    _root.count_down.text = time_to_string(_root.countdown-elapsed_time);
if (elapsed_time >= countdown) {
removeMovieClip(_root.tiles);
removeMovieClip("frame");
            gotoAndPlay("lose");
};
}

function time_to_string(time_to_convert) {
    elapsed_hours = Math.floor(time_to_convert/3600000);
    remaining = time_to_convert-(elapsed_hours*3600000);
    elapsed_minutes = Math.floor(remaining/60000);
    remaining = remaining-(elapsed_minutes*60000);
    elapsed_seconds = Math.floor(remaining/1000);
    remaining = remaining-(elapsed_seconds*1000);
    elapsed_fs = Math.floor(remaining/10);
    if (elapsed_hours<10) {
        hours = "0"+elapsed_hours.toString();
    } else {
        hours = elapsed_hours.toString();
    }
    if (elapsed_minutes<10) {
        minutes = "0"+elapsed_minutes.toString();
    } else {
        minutes = elapsed_minutes.toString();
    }
    if (elapsed_seconds<10) {
        seconds = "0"+elapsed_seconds.toString();
    } else {
        seconds = elapsed_seconds.toString();
    }
    if (elapsed_fs<10) {
        hundredths = "0"+elapsed_fs.toString();
    } else {
        hundredths = elapsed_fs.toString();
    }
    return minutes+":"+seconds+":"+hundredths;
}

```

Now i want it to be so there is an item on the map that you can pick up that will add time to the countdown

how would i go about doing this?

-The Joe Knows
