# setProperty question

**URL:** <https://forum.kirupa.com/t/setproperty-question/6946>\
**Category:** flash\
**Created:** [October 20, 2002, 6:49pm UTC](https://forum.kirupa.com/t/setproperty-question/6946 "2002-10-20T18:49:31Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![supernaut](https://avatars.discourse-cdn.com/v4/letter/s/c2a13f/32.png) [@supernaut](https://forum.kirupa.com/u/supernaut)\
**Post date:** [October 20, 2002, 6:49pm UTC](https://forum.kirupa.com/t/setproperty-question/6946/1 "2002-10-20T18:49:31Z")

</div>

Im trying to optimise my code a bit so i dont have ten lines of identical code on each button. Actionscript is not my strong point. Currently on each of the menu buttons there is this code:

// sets the vertical position of all scrollbars (name0) inside their content movieclips //(name) to \_y = 0

on (release) {  
setProperty(“work1.carni.carni0”, \_y, “0”);  
setProperty(“work1.dead.dead0”, \_y, “0”);  
setProperty(“work1.super.super0”, \_y, “0”);  
setProperty(“work1.scan.scan0”, \_y, “0”);  
setProperty(“work1.zero.zero0”, \_y, “0”);  
setProperty(“work1.blow.blow0”, \_y, “0”);  
setProperty(“work1.pirn.pirn0”, \_y, “0”);  
}

what i’d like to do is some kind of function like this, which does all the work in a frame on the main timeline. For example:

on each button:

// tells every “name0” mc to set \_y to 0 within their respective content movieclips  
on (release) {  
vertical = (\_y = 0);  
verticalHold(vertical);  
}

on the main timeline something like this:

// Get the command from the buttons and run the function and set all “name0” \_y to 0  
function verticalHold(vertical) {  
setProperty(allName0Clips(vertical));  
}

i’ve played around with this function for loading external swfs, but i have no idea how to make it set multiple \_y positions. any suggestions? what about putting all the mc names into an array (called “allName0Clips”) and doing it that way?

cheers

supernaut

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 20, 2002, 9:27pm UTC](https://forum.kirupa.com/t/setproperty-question/6946/2 "2002-10-20T21:27:20Z")

</div>

First of all, forget about setProperty. Use the dot syntax.

Then your idea is good: put all the clips in an array, and then use a loop. Something like:

```auto
myArray=["blabla0","iiii0"];
for (var i=0;i < myArray.length;i++){
    work1[myArray*]._y=0;
}

```

Something like that 🙂

pom :asian:

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 21, 2002, 8:08am UTC](https://forum.kirupa.com/t/setproperty-question/6946/3 "2002-10-21T08:08:48Z")

</div>

thanks heaps for your help. check it out at [::: dance sucker dance :::](http://www.zeroballet.info) in the works section

MY SOLUTION:

code:

* * *

//this resets the vertical position of all menu content scroll bars to \_y = 0  
vert = [“carni”, “dead”, “super”, “scan”, “zero”, “blow”, “pirn”];

function resetVert() {  
for (i=0; i\<vert.length; i++) {  
this.work1[vert\*][vert\* + “0”].\_y = 0;  
}  
}

//this resets the vertical position of all menu content scroll bars  
//to \_y = 0 via a function in main timeline

on (release) {  
resetVert();  
}

* * *

thanks again,

supernaut
