setProperty question

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(“”, _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);

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) {

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?



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:

for (var i=0;i < myArray.length;i++){

Something like that :slight_smile:

pom :asian:

thanks heaps for your help. check it out at ::: dance sucker dance ::: in the works section



//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) {

thanks again,