Problem with Functions and onRelease

Hi

Strangely enough I can’t access the variable i in the onRelease function below. I guess it must have something to do with the position where I declared it. But I also tried to declare it outside of the functions but it didn’t work either… Do you guys have any idea how to solve this problem?

function loadXML(loaded) {
	if (loaded) {
		xmlNode = this.firstChild;
		var thumbnail:Array = [];
		var image:Array = [];
		var imagetitle:Array = [];
		var description:Array = [];
		var total:Number = xmlNode.childNodes.length;
		for (i = 0; i < total; i++) {
			var thumblength:Number = 50;
			var gap:Number = 10;
			var newX:Number = i * thumblength + 10;
			trace("NewX " + newX);
			thumbnail* = xmlNode.childNodes*.attributes.thumbnail;
			imagetitle* = xmlNode.childNodes*.attributes.title;
			trace("currentnodeINDEX= " + currentnodeIndex*);
			newsContainer.attachMovie("thumbnail", "thumb" + i, newsContainer.getNextHighestDepth(), {_x:newX});
			newsContainer["thumb" + i].onRelease = function() {
				trace("Variable equals " + i)
			};
			// do something
		}
	} else {
		content = "file not loaded!";
	}
}