Hi, I’m trying to create a template for a drag and drop question. I want to assign which option belongs to the correct target.
Each draggable option is called “drag1, drag2, drag3, etc.”. (created on the stage)
Each target is called “target1, target2, target3, etc.”
When a button is clicked, the correct answer is checked using a simple if loop and the user is told which ones are correct.
if (drag1._y = target1._y) {
//show if correct or incorrect
}
I understand it’s an inefficient way of doing things, but I’d like to keep the code for the moment. What I’d like to do is create the variable name “drag1” from another variable, i.e
var ans1:Number = 1;
var ans2:Number = 2;
if (drag+ans1._y = target1._y) {
//show if correct or incorrect }
I’ve tried this, but it just doesn’t work and it’s annoying me not knowing if it’s possible or not.