# Problem with Functions and onRelease

**URL:** <https://forum.kirupa.com/t/problem-with-functions-and-onrelease/201639>\
**Category:** flash\
**Created:** [September 23, 2006, 12:27pm UTC](https://forum.kirupa.com/t/problem-with-functions-and-onrelease/201639 "2006-09-23T12:27:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![oaki](https://avatars.discourse-cdn.com/v4/letter/o/7993a0/32.png) [@oaki](https://forum.kirupa.com/u/oaki)\
**Post date:** [September 23, 2006, 12:27pm UTC](https://forum.kirupa.com/t/problem-with-functions-and-onrelease/201639/1 "2006-09-23T12:27:50Z")

</div>

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?

```auto
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!";
	}
}

```
