Skip to main content
Participating Frequently
March 16, 2012
Answered

calling a variable in an instance name

  • March 16, 2012
  • 1 reply
  • 463 views

Maybe I am far off here, but I'm hoping someone can help.

Basically I'm creating a question with 4 answers (i.e. a,b,c,d).

I have my question working fine, but I'm having a problem adding a check mark beside the answers once the user clicks the submit button.

I've created four instances of my check mark; rightAns1_mc, rightAns2_mc, rightAns3_mc, rightAns4_mc.  I've set them all to _invisible = false;

I've also set up a variable; nCheck:Number = 0; and when the user clicks one the radial buttons I have the variable change (i.e. if they click A, it set to nCheck = 1; if they click B, it sets to nCheck = 2; etc)

So in my if statement for the submit button I figured I could have rightAns(nCheck)_mc._visible = true;

This completely breaks everything. Like I said, I'm probably far off here. If I am what should I do differently, and if I'm close what am I doing wrong?

This topic has been closed for replies.
Correct answer kglad

use array notation to coerce flash to resolve strings to objects:

this["rightAns"+nCheck+"_mc"]._visible=true;

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
March 16, 2012

use array notation to coerce flash to resolve strings to objects:

this["rightAns"+nCheck+"_mc"]._visible=true;