Reload "function init()"

I am using the UI Component set2 Calendar. I have some extra code that highlights desired dates in blue.


CustomDateFilter = function(component, testo)
{
	this.component = component;
	this.testo = testo;
	this.days = [];
};
CustomDateFilter.prototype.insertDate = function(day, month, year, description)
{
	var obj = {data:new Date(year, month - 1, day), description:description};
	this.days.push(obj);
};
CustomDateFilter.prototype.removeDate = function(day, month, year)
{
	var data = new Date(year, month - 1, day).toString();
	for(var i = 0; i < this.days.length; i++){
		if(this.days*.data.toString() == data){
			this.days.splice(i, 1);
			this.component.StepDate(0,0);
			return true;
		}
	}
	return false;
};
CustomDateFilter.prototype.isSelectable = function(component, day)
{
	return true;
}
CustomDateFilter.prototype.isHighlighted = function(component, day)
{
	for(var i = 0; i < this.days.length; i++){
		if(day.toString() == this.days*.data.toString())	return true;
	}
	return false;
}
CustomDateFilter.prototype.getDate = function()
{
	var data = this.component.getSelectedItem().toString();
	for(var i = 0; i < this.days.length; i++){
		if(data == this.days*.data.toString()){
			this.testo.text = this.days*.description;return;
		}
	}
	this.testo.text = "no data";
};

function init(){
	var data = new Date();
	var month = data.getMonth() + 1;
	var year = data.getFullYear();
	var range = new Object();
	range.begin = new Date(year, (month - 1) - 2);
	range.end = new Date(year, (month - 1) + 2);
	filtro = new CustomDateFilter(cpCalendar, text_txt);
	filtro.insertDate(8, month, 2003, "Birthday - Mario Rossi");
	filtro.insertDate(14, month, 2003, "Appointment - Marco");
	filtro.insertDate(30, month, 2003, "Anniversary - Andrea and Laura");
	filtro.insertDate(24, month + 1, 2003);
	
	cpCalendar.setDisplayRange(range);
	cpCalendar.setDateFilter(filtro);
	//cpCalendar.setChangeHandler("getDate", filtro);
	cpCalendar.setStyleProperty("selectedDateBackground", 0xFF9900);
	cpCalendar.setStyleProperty("customDateBackground", 0x006699);
}
init();

This codes works great but I need to wait a bit before I call it. My highlighted dates will not be hard coded they will dynamic, so I have to what until my data loads into flash before the desired dates can be called. I have tried putting this code in a button and invoking it after my data loads but nothing happens. I assume the way the code is written it only works when the calendar is first load. Is there a way around this?