# Scope of a variable?

**URL:** <https://forum.kirupa.com/t/scope-of-a-variable/153011>\
**Category:** flash\
**Created:** [June 28, 2005, 6:45pm UTC](https://forum.kirupa.com/t/scope-of-a-variable/153011 "2005-06-28T18:45:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![viewsonic](https://avatars.discourse-cdn.com/v4/letter/v/b19c9b/32.png) [@viewsonic](https://forum.kirupa.com/u/viewsonic)\
**Post date:** [June 28, 2005, 6:45pm UTC](https://forum.kirupa.com/t/scope-of-a-variable/153011/1 "2005-06-28T18:45:36Z")

</div>

Hi every1! I got this code:

```auto
cycle for 1<i<10:
_root["containter"+i].onRelease = function () {
	_root.play();
	_root.blackout.gotoAndPlay(1);
	_root.media2load = "works/" + myVars["media"+i];
}
end of cycle

```

So, when I check then “\_root.media2load” after I click on the container1 (for example) it says “undefined”. So, I guess the cycle doesn’t go into this function and work it out only when the flash is playing and when I click on that container. But then the variable “i” has the its last value = 10.  
What should I do?
