# AS Code Cleaning

**URL:** <https://forum.kirupa.com/t/as-code-cleaning/33164>\
**Category:** Uncategorized\
**Created:** [October 15, 2003, 10:41pm UTC](https://forum.kirupa.com/t/as-code-cleaning/33164 "2003-10-15T22:41:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![BVision](https://avatars.discourse-cdn.com/v4/letter/b/e56c9b/32.png) [@BVision](https://forum.kirupa.com/u/BVision)\
**Post date:** [October 15, 2003, 10:41pm UTC](https://forum.kirupa.com/t/as-code-cleaning/33164/1 "2003-10-15T22:41:33Z")

</div>

I have no problem w/the following AS, it works exactly as I want it to. I see a very definite pattern here, where the mcX and the Writings\_text[X] are the exact same number. I have tried to condense these numerous onRelease commands into one loop type structure with no luck.  
[AS]\_root.mc[COLOR=red]X[/COLOR].onRelease = function() {  
loadVariablesNum(Writings\_text[[COLOR=red]X[/COLOR]]+".txt", 0);  
};[/AS]I would like to have only 1 onRelease function instead of repeating it however many # of times I have my mc’s duplicated.  
I would appreciate any feedback concerning this.  
[AS]for (i=0; i\<=Writings\_text.length-1; i++) {  
duplicateMovieClip(shell\_button, “mc”+i, i);  
setProperty(“mc”+i, \_x, x=5);  
setProperty(“mc”+i, \_y, y += 25);  
\_root[“mc”+i].link = Writings\_text\*;  
}  
\_root.mc0.onRelease = function() {  
loadVariablesNum(Writings\_text[0]+".txt", 0);  
};  
\_root.mc1.onRelease = function() {  
loadVariablesNum(Writings\_text[1]+".txt", 0);  
};  
\_root.mc2.onRelease = function() {  
loadVariablesNum(Writings\_text[2]+".txt", 0);  
};  
\_root.mc3.onRelease = function() {  
loadVariablesNum(Writings\_text[3]+".txt", 0);  
};  
\_root.mc4.onRelease = function() {  
loadVariablesNum(Writings\_text[4]+".txt", 0);  
};  
\_root.mc5.onRelease = function() {  
loadVariablesNum(Writings\_text[5]+".txt", 0);  
};  
\_root.mc6.onRelease = function() {  
loadVariablesNum(Writings\_text[6]+".txt", 0);  
};  
\_root.mc7.onRelease = function() {  
loadVariablesNum(Writings\_text[7]+".txt", 0);  
};  
\_root.mc7.onRelease = function() {  
loadVariablesNum(Writings\_text[7]+".txt", 0);  
};  
\_root.mc8.onRelease = function() {  
loadVariablesNum(Writings\_text[8]+".txt", 0);  
};  
stop();[/AS]
