[fmx] assign onPress to createEmptyMovieClip

Hi,

I have a problem with my script. I’m trying to create text buttons with URLs loaded from a XML file. Up till now i’ve loaded the URL string and created the text buttons successfully. But I have a problem assigning the onPress event.

 
parseWebsite = function(oWeb){
var offsetX =100;
var myFmt:TextFormat = new TextFormat();
myFmt.color = 0xFFFFFF;
myFmt.font = "Harmony";
myFmt.size = 8;
 
for (var i=0; i<oWeb.sectionList.length; i++){
var currentMC = this.createEmptyMovieClip(oWeb.sectionList*["title"], this.getNextHighestDepth());
currentMC.createTextField("name", this.getNextHighestDepth(),10+(i*offsetX),50,400,22);
currentMC.name.embedFonts = true;
currentMC.name.text = oWeb.sectionList*["title"];
currentMC.name.setTextFormat(myFmt);
 
currentMC.onPress = function(){
trace(oWeb.sectionList*["link"]);
}
}
}

The above function takes the object containing the URL strings to create the text buttons and assigning the onPress event to them. The function however traces an undefined for all the buttons when clicked.

I know that you have to wait for the MC to complete loading before assigning onPress because the clip “refreshes”, but I thought its for loading JPGs only. Can anyone help? Thanks!