Ripple_in_Eternity
04-08-2009, 06:12 PM
So, I'm coding a fairly complicated and elaborate project, and along comes Mr. Coding Problem.
The short of this is, what I believe to be local variables in a class are acting like they're a class value, in that there's only one value per class. Essentially: what I like to call "sticky vars".
Well I've got a bad case of the sticky vars and it's getting itchy.
function HueGene (Set0 : Array, Set1 : Array)
{
for (var u = 0; u < 8; u ++)
{
this["C" + (u + 1)][0] = Set0 [u]
this["C" + (u + 1)][1] = Set1 [u]
}
}
This is part of my class definition function and what I believe to be the source of the error. Perhaps I'm defining it improperly, perhaps the flash gods dislike me. The arrays "C1" through "C8" are the cause of my frustration.
The problem is however, that the values for these arrays are generated randomly, (granted I am using the random() function, but changing it to Math.random() didn't change so much as a byte.) but several of the variables end up being the same value.
More troubling, is the fact that this stickiness is inconsistent, and I'm having quite the time trying to figure out where I made this rather annoying boo-boo.
Anyone with an idea as to how to fix this would be appreciated. The last time I coded myself into this corner, I abandoned the project, and would be sad to lose this game to the nether-regions of my hard drive.
The short of this is, what I believe to be local variables in a class are acting like they're a class value, in that there's only one value per class. Essentially: what I like to call "sticky vars".
Well I've got a bad case of the sticky vars and it's getting itchy.
function HueGene (Set0 : Array, Set1 : Array)
{
for (var u = 0; u < 8; u ++)
{
this["C" + (u + 1)][0] = Set0 [u]
this["C" + (u + 1)][1] = Set1 [u]
}
}
This is part of my class definition function and what I believe to be the source of the error. Perhaps I'm defining it improperly, perhaps the flash gods dislike me. The arrays "C1" through "C8" are the cause of my frustration.
The problem is however, that the values for these arrays are generated randomly, (granted I am using the random() function, but changing it to Math.random() didn't change so much as a byte.) but several of the variables end up being the same value.
More troubling, is the fact that this stickiness is inconsistent, and I'm having quite the time trying to figure out where I made this rather annoying boo-boo.
Anyone with an idea as to how to fix this would be appreciated. The last time I coded myself into this corner, I abandoned the project, and would be sad to lose this game to the nether-regions of my hard drive.