for (r=1; r<4; r++) {
if (_level0.beml_side[r] == “Inferno”) {
indside[r] = 1;
} else if (_level0.beml_side[r] == “Storm”) {
indside[r] = 2;
} else if (_level0.beml_side[r] == " ") {
indside[r] = 3;
} else {
ind_side[r] = 0;
}
trace(indside[r]);
side[r].setSelectedIndex(indside[r]);
}
indside1, 2 and 3 all come up undefined. If I don’t use the for loop it works fine.
Now this really depends upon what it is you’re trying to test for. The _name property of a movie clip is the instance name that you assigned to the movie clip itself. If you’re looking to test for a url name then I’m not sure yet how to do that.
Err. I don’t think it’s the name I’m trying to get.
_level0.beml_side1 = “Storm”
_level0.beml_side2 = “Storm”
_level0.beml_side3 = “Storm”
These values are all strings loaded up from a .txt file when the flash starts. I know it gets that far because I can check the values of these not only in the .txt file but also in the flash where it is aware of it too. If I replace the “[r]” with a number (say 2) it will execute the code correctly.
Edit: Before I had the for loop I had it in 3 separate if statements. One for each beml_side. It worked fine then. I then decided to add another value and condense the code into that for loop and it kinda went wonky.
Keep in mind that this all depends upon where those variables are supposed to be located. If the variables like “inside1” is locaed somewhere other than the _root timeline you’ll need to set the path there.
The important thing to note when using the brackets like this, in dot syntax is that a dot is NOT placed before the brackets but it is placed after them. So if we were setting the alpha property of a movie clip it would look liike this.
Ok that seemed to change the output but didn’t fix it… It’s now giving me the “else” outcome. I have a feeling it’s because the if statement is asking if the string “”_level0.beml_side"+r" is = to “Storm”. It’s not calculating the variable any further than _level0.beml_side1 for example.
hmm… let me think on the delema… you keep working on it and post any additional quirks you may encounter… If we can’t solve it now, then you can send me the file at my email and I’ll look at it in the morning.
Well what confused me was the fact that I could have sworn I had a script somewhere that had a for loop using pieces of code like the following.
[AS]for (x=1; x<10; x++) {
variable[x] = y;
}[/AS]
you might have had that. What it’s calling there is to an Array, not a variable. In the case of an array, there is a name, then an open bracket, then a number (or name of feild) then a close bracket.
like so
myArray[0] = the first object in the array.
so in the case of
for (x=1; x<10; x++) {
variable[x] = y;
}
The script is looping 9 times, and setting a number of slots in the array called “variable” (which is confusing. cause we never name anything variable) equal to y.
I’ve come across something in C programming that I’ve started to use in my action scripting. I begin any created object, variable, or array with a lower case letter of the type. This is very helpful once you’re scripts get large and confusing. I wish other would do it too, but as of yet it hasn’t caught on.
some examples
with the lowercase letters first… I always know exactly what I’m looking at when I’m working my code. I hope that I can convince at least the people here to start using this format… but who knows… people don’t like change.
You’re right. It was a array. I like the idea of appending that letter to the start of an object, variable etc. to describe what it is so just for you I’ll start doing it… even if I don’t display my code frequently I’ll probably benefit from it a lot.