Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

updating an array's index values

Status
Not open for further replies.

bugg

Programmer
Jun 20, 2001
62
US
okay, this is killing me, I don't have the patience to sit here and toy with this anymore. Hopefully somebody out there can help me with this...

I have an array of mcs, I want to pass a random grouping of them to a function on the press of a button, I have this sitting in the first frame of my movie:

//variables

arraySize = 30
randomNumber = 0;

//functions

function prep (player) {
player._alpha=33;
};

function scaleup (player) {
player._alpha=100;
player._xscale=200;
player._yscale=200;
};

function scaledown (player) {
player._alpha=33;
player._xscale=100;
player._yscale=100;
};

//arrays

playerArray = new Array (_root.a1, _root.a2, _root.a3, _root.a4, _root.a5, _root.a6, _root.a7, _root.b1, _root.b2, _root.b3, _root.b4, _root.b5, _root.b6, _root.b7, _root.c1, _root.c2, _root.c3, _root.c4, _root.c5, _root.c6, _root.c7, _root.d1, _root.d2, _root.d3, _root.d4, _root.d5, _root.d6, _root.d7, _root.e1, _root.e2, _root.e3, _root.e4, _root.e5, _root.e6, _root.e7);

booleanArray = new Array (_root.arraySize);

I then have this on the button:

on (release) {
randCount = random (_root.arraySize - 1);
for (j=0; j < randCount; j++) {
_root.randomNumber = random(_root.arraySize - 1);
if (booleanArray[_root.randomNumber] != true) {
booleanArray[_root.randomNumber] = true;
}
else {
j--;
}
};
for (q=0; q < _root.arraySize; q++) {
if (booleanArray[q] == true) {
_root.novis(movieclipArray[q])
}
};
for (k=0; k < (_root.arraySize - 1); k++) {
booleanArray[k] = false;
}
}

when I debug the movie, I see the variables randCount and randomNumber updating, but the index values of booleanArray don't update. Anybody got any ideas?

tia
bugg
 
er, sorry, the function call is incorrect, it should read:

for (q=0; q < _root.arraySize; q++) {
if (booleanArray[q] == true) {
_root.scaleup(movieclipArray[q])
}
};
thanks
bugg
 
okay, sorry (I concede, I am a dumb-a**)

I figured it out, I was passing indexes of an array that didn't exist (movieclipArray) instead of playerArray. that will teach me to spread a code across several documents while trying to figure it out. sorry to have taken so much room here, and thanks to all those who would've been happy to point out the obvious...

out
bugg
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top