Multiple Alarm Variables

Hello, I’m making an alarm application with many features, one of them being the ability to have multiple alarms running at one time. Although not yet complete, I’m able to have one alarm, and if I try to set another, all alarms adjust to the one alarm setting. I believe it is overwriting the variables for the alarm times.


function set_alarm(alarm_hr_1, alarm_min_1, am_pm:Boolean) {
	alarm_hr = parseInt(alarm_hr_1) //Originally strings
	alarm_min = parseInt(alarm_min_1)
	if (isNaN(alarm_hr) == true) {
		error_snd.start()
		remove_alarm()
	}else if (isNaN(alarm_min) == true) {
		error_snd.start()
		remove_alarm()
	}else{
		num_alarm++;
		var target_alarm:MovieClip = new MovieClip();
		target_alarm = createEmptyMovieClip("alarm"+num_alarm, _root.getNextHighestDepth())
		target_alarm.moveTo(0,0)
		target_alarm.lineStyle(1, 0x000000, 0)
		target_alarm.beginFill(0x000000, 0)
		target_alarm.lineTo(50, 0)
		target_alarm.lineTo(50, 11)
		target_alarm.lineTo(0, 11)
		target_alarm.lineTo(0,0)
		target_alarm.endFill()
		target_alarm._x = 20
		target_alarm._y = 40
		target_alarm.createTextField("alarm_txt", _root.getNextHighestDepth(), 0, 0, 100, 11)//_x = 20, _y = 40
		target_alarm.alarm_txt.type = "dynamic"
		target_alarm.alarm_txt.selectable = false;
		target_alarm.alarm_txt.embedFonts = true;
		target_alarm.alarm_txt._alpha = 0
		fadeTo(target_alarm.alarm_txt, 100, false)
		if (num_alarm>1) {
			slideToY(target_alarm,target_alarm._y+(12*(num_alarm-1)), 0.7) //Note - slideToY is a function that I made to speed up tweening.
		}
		num_alarm == max_alarm ? alarm_btn.enabled = false : alarm_btn.enabled = true
	}
	alarm_hr = am_pm == true ? alarm_hr += 12 : alarm_hr;
	function update_alarm() {
		var current_date:Date = new Date()//To get the standards for the alarm time
		if (alarm_msecs>current_msecs) {
			var alarm_date:Date = new Date(current_date.getFullYear(),current_date.getMonth(), current_date.getDate(), alarm_hr, alarm_min, 			current_date.getSeconds(), current_date.getMilliseconds())
		}else{
			var alarm_date:Date = new Date(current_date.getFullYear(), current_date.getMonth(), current_date.getDate()+1, alarm_hr, alarm_min, current_date.getSeconds(), current_date.getMilliseconds())
		}

               /*I believe the problem is in here*/
		var time_rem:Date = new Date()
		var alarm_msecs = alarm_date.getTime()//Gets the milliseconds for alarm
		var current_msecs = time_rem.getTime()//Gets the current milliseconds
		var alarm_msecs_rem:Number = alarm_msecs-current_msecs;
		var alarm_mins_rem = Math.ceil(alarm_msecs_rem/60000); // 60 000 milliseconds make a minute
		var alarm_hr_rem = Math.floor(alarm_mins_rem/60); // 60 minutes make a hour
		
		alarm_mins_rem = String(Math.ceil(alarm_mins_rem % 60));
		alarm_hr_rem = String(Math.floor(alarm_hr_rem % 24));
		if (alarm_mins_rem.length < 2) alarm_mins_rem = "0" + alarm_mins_rem;
		if (alarm_hr_rem.length < 2) alarm_hr_rem = "0" + alarm_hr_rem;
		
		target_alarm.alarm_txt.text = alarm_hr_rem +" : "+ alarm_mins_rem;
		target_alarm.alarm_txt.setTextFormat(txt_fmt);
}
//There is more, it's just irrelevant.

I have also tried to set the alarm_mins_rem, and alarm_hr_rem variables to variables within the movieclip [target_alarm or alarm+num_alarm] but to no avail. I believe I may have done something wrong but I don’t know.


var time_rem:Date = new Date()
target_alarm.alarm_msecs = alarm_date.getTime()//Gets the milliseconds for alarm
var current_msecs = time_rem.getTime()//Gets the current milliseconds
target_alarm.alarm_msecs_rem = target_alarm.alarm_msecs-current_msecs;
target_alarm.alarm_mins_rem = Math.ceil(target_alarm.alarm_msecs_rem/60000); // 60 000 milliseconds make a minute
target_alarm.alarm_hr_rem = Math.floor(target_alarm.alarm_mins_rem/60); // 60 minutes make an hour

If anyone could help me figure out how not to overwrite these, it would be a great help.

PS
Is it possible to forcibly remove focus from a textfield and if so, how?