# Converting code for timer project from AS2 to AS3

**URL:** https://forum.kirupa.com/t/converting-code-for-timer-project-from-as2-to-as3/296922
**Category:** flash
**Created:** [September 22, 2009, 7:17pm UTC](https://forum.kirupa.com/t/converting-code-for-timer-project-from-as2-to-as3/296922 "2009-09-22T19:17:09Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Coolidge](https://avatars.discourse-cdn.com/v4/letter/c/dec6dc/32.png) [@Coolidge](https://forum.kirupa.com/u/Coolidge)
#### Post date: [September 22, 2009, 7:17pm UTC](https://forum.kirupa.com/t/converting-code-for-timer-project-from-as2-to-as3/296922/1 "2009-09-22T19:17:09Z")

</div>

Hi all,  
Would anyone be interested in helping me convert this code from AS2 to AS3? Any tips or assistance would be greatly appreciated 🙂

Thank you!

```auto

Timer = function () {
};

Timer.prototype.Play = function(delay, area, callBackObj, callBackFunc) {
 	this.iniTime = getTimer(); 
	this.delay = delay*1000; 
	this.area = area;
	this.frames = 120;
	this.callBackObj = callBackObj;
	this.callBackFunc = callBackFunc;
	this.onEnterFrame = this.doMotion;
};
Timer.prototype.doMotion = function() {
 	this.curTime = getTimer();
	if((this.curTime-this.iniTime)>this.delay) {
		this["timask"+this.area].gotoAndPlay("fin");
		delete this.onEnterFrame;
		if(this.callBackObj!=undefined) {
			this.callBackObj[this.callBackFunc]();
		} 
	} else {
		c_frame = Math.floor(((this.curTime-this.iniTime)*(this.frames*this.area))/this.delay)+1*this.area;
		this["timask"+this.area].gotoAndStop(c_frame); 
	}
};

Timer.prototype.Stop = function() {
	if(this.onEnterFrame) delete this.onEnterFrame;
};

timer3. __proto__ = Timer.prototype;

b_test.onRelease = function() {
	timer3.Play(Number(5),2,_root,"doSomething");
}

function doSomething() {
	this.output.text = "Try Again!";
}

```
