# \[MX\] - Get me beyond the evil eval!

**URL:** <https://forum.kirupa.com/t/mx-get-me-beyond-the-evil-eval/140314>\
**Category:** Uncategorized\
**Created:** [March 10, 2005, 2:57am UTC](https://forum.kirupa.com/t/mx-get-me-beyond-the-evil-eval/140314 "2005-03-10T02:57:34Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![greatbigbrain](https://avatars.discourse-cdn.com/v4/letter/g/3be4f8/32.png) [@greatbigbrain](https://forum.kirupa.com/u/greatbigbrain)\
**Post date:** [March 10, 2005, 2:57am UTC](https://forum.kirupa.com/t/mx-get-me-beyond-the-evil-eval/140314/1 "2005-03-10T02:57:34Z")

</div>

Okay all you smarty pants out there… I seem to always stumble on this – every app I build requires something similar. Here’s a simple example; if someone could please show me a better way to do it, and also explain exactly what it is they’re doing, I would benefit greatly. Apparently using eval() is a bad thing. So help me get beyond it! Please! Pleeeeeease!:

```auto
for (var i:Number = 1; i < 10; i++) {
	var mcButton:MovieClip = eval("but"+i+"_mc");
	mcButton.activeLayer = i;
	mcButton.onRelease = function():Void {
		trace("Button "+this.activeLayer+" pressed");
		var mcLayer:MovieClip = eval("layer"+this.activeLayer+"_mc");
		mcLayer._visible = !mcLayer._visible;
	}
	
}

```

Okay, so what’s the best way to write this?  
Basically just telling some MovieClips to make some other MovieClips invisible/visible when they’re clicked on.

Thanks all – you’re all wonderful people.

Steve
