# Abbreviating code when targeting instances in AS

**URL:** <https://forum.kirupa.com/t/abbreviating-code-when-targeting-instances-in-as/233203>\
**Category:** flash\
**Created:** [July 21, 2007, 4:15am UTC](https://forum.kirupa.com/t/abbreviating-code-when-targeting-instances-in-as/233203 "2007-07-21T04:15:55Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![thalamus](https://avatars.discourse-cdn.com/v4/letter/t/0ea827/32.png) [@thalamus](https://forum.kirupa.com/u/thalamus)\
**Post date:** [July 21, 2007, 4:15am UTC](https://forum.kirupa.com/t/abbreviating-code-when-targeting-instances-in-as/233203/1 "2007-07-21T04:15:55Z")

</div>

Some time ago in a Kirupa post i saw a way to abbreviate instance targeting and cut down on the code using a for loop or while loop or something like that, but can’t remember what it was:

so instead of

myMovieclip\_mc.btn1\_btn.enabled = false;  
myMovieclip\_mc.btn2\_btn.enabled = false;  
myMovieclip\_mc.btn3\_btn.enabled = false;  
myMovieclip\_mc.btn4\_btn.enabled = false;  
myMovieclip\_mc.btn5\_btn.enabled = false;  
myMovieclip\_mc.btn6\_btn.enabled = false;

the shorter version was something like this;

while (myMovieClip\_mc) {  
btn1\_btn.enabled = false;  
btn2\_btn.enabled = false;  
btn3\_btn.enabled = false;  
btn4\_btn.enabled = false;  
btn5\_btn.enabled = false;  
btn6\_btn.enabled = false;  
}

so I don’t have to type **myMovieClip\_mc** 6 times.

How does that go exactly? Thanks.
