# Timer and action

**URL:** <https://forum.kirupa.com/t/timer-and-action/198489>\
**Category:** Uncategorized\
**Created:** [August 25, 2006, 2:25pm UTC](https://forum.kirupa.com/t/timer-and-action/198489 "2006-08-25T14:25:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![gh\_](https://avatars.discourse-cdn.com/v4/letter/g/ecc23a/32.png) [@gh\_](https://forum.kirupa.com/u/gh_)\
**Post date:** [August 25, 2006, 2:25pm UTC](https://forum.kirupa.com/t/timer-and-action/198489/1 "2006-08-25T14:25:33Z")

</div>

Currently I have the first set of AS below that closes a window by clicking on a button. I would like to close the window automatically after 5 seconds have elapsed from the time the window is opened, the Last set of AS that is below is used to open the window. The middle set of AS is from a tutorial. I am needing help putting this all together.

What i would like to happen is when the window is opened

contact\_btn.onPress = function(){  
contactLoader.load(“contact.swf”);  
}

after 5 seconds the window closes using the tween close from the middle section below

Thanks So Much for Helping in Advance

close\_btn.onPress = function(){  
new mx.transitions.Tween(\_root.firstLoader.content.contactLoader.content, “\_alpha”, mx.transitions.easing.Regular.easeOut, \_root.firstLoader.content.contactLoader.content.\_alpha, 0, 20);

var interval:Number = 5;  
function someCodeToRun() {  
clearInterval(mySetInterval);  
trace(interval+" seconds have elapsed");  
}  
mySetInterval = setInterval(this, “someCodeToRun”, interval\*1000);

contact\_btn.onPress = function(){  
contactLoader.load(“contact.swf”);  
}
