0

I would know how insert an array in an if of a for loop nested in another for loop.

for (var q...){
for (var u...){ 
 if ("array_"+q+"["+u+"]" == "[object object1]") {
 object1 = ++object1;}
 ...
...

"array_"+q+"["+u+"]" can be traced for example like:

array_1[0], array_1[1], array_1[2], array_1[3]
array_2[0], array_2[1], array_2[2], array_2[3] etc...

But if I try to check if is equal to [object object1] it doesn't work.

What's wrong in the syntax below?

if ("array_"+q+"["+u+"]"

1 Answer 1

2

What's wrong in the syntax below?

That this: "array_"+q+"["+u+"]" is a string. A string is not a reference to your array, it is just... string. If you want to use something like that, you have to do it like this:

this["array_"+q][u]; //this would be a reference! Note this would work only with dynamic objects (= MovieClips, or your class declared as dynamic)

Sign up to request clarification or add additional context in comments.

1 Comment

You are welcome. Please consider marking this question as solved (the checkbox next to the answer).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.