Copy link to clipboard
Copied
I'm trying to change visibility of objects on screen using this.
this["answers" + currentQuestionNum + "." + "answer" + currentQuestionNum + "_d"].visible = 0 |
so if currentQuestionNum = 1, it does answers1.answer1_d.visible = 0
but I got the following error:
TypeError: Error #1010: A term is undefined and has no properties.
at _211_fla::interaction_1/setupQuestionFrame()
at _211_fla::interaction_1/frame3()
at flash.display::MovieClip/gotoAndStop()
at _211_fla::interaction_1/gotoNextQuestion()
at MethodInfo-163()
If I do:
trace("answers" + currentQuestionNum + "." + "answer" + currentQuestionNum + "_d"); |
It shows the string answers1.answer1_d correctly.
How can I make it work?
Thanks,
You need two sets of brackets - one for the main object, and one for its child. This should work:
this["answers" + currentQuestionNum]["answer" + currentQuestionNum + "_d"].visible = 0;
Copy link to clipboard
Copied
I searched on Error #1010: and one possibility is that the object is not there when the script runs. It does not look like it as I can put answers1.answer1_d.visible = false and the object would be hidden without any error.
Copy link to clipboard
Copied
You need two sets of brackets - one for the main object, and one for its child. This should work:
this["answers" + currentQuestionNum]["answer" + currentQuestionNum + "_d"].visible = 0;
Copy link to clipboard
Copied
You're the savior, dmennenoh. THANKS A LOT!
Never thought of that you don't need to include "." for it to know parent and child relationship.
Thanks again for solving this issue that bothered me for a long time.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now