But of course I have created another problem, when I change the ivar to i-19 rather than just i, it affects the wrong answer outcome.
The questions loads correctly, in other words whatever number state is clicked on, this is question with the correct state number is returned, but it turns a completely different state black (which is the color set for when a wrong answer is selected)
Here is what I have looked at:
They are turning states black that are exactly 19 less than the number of the state clicked on.
Like if I click on state 39 it will turn state 10 black when I select an answer.
So I do know by changing definition of ivar to start at 19 rather than 0, I have thrown off the results by 19 as well. Finding out how to correct this is my challenge.
I thought at first it would have something to do with the code on the question movie clip (holder) which is this code:
comp0.setLabel(_root.comp0var);
comp1.setLabel(_root.comp1var);
comp2.setLabel(_root.comp2var);
comp3.setLabel(_root.comp3var);
function checkradio() {
trace(radiogroup.getValue());
//states 0 through 18 should be disabled by this loop
//because it is only set for 19 through 47 (I think?)
for (var i = 19; i<48; i++) {
_root[“mystate”+i].enabled = true;
}
[COLOR=DarkRed]for (var j = 0; j<_root.pressedArray.length; j++) {
_root.pressedArray[0].enabled = false;[/COLOR]
}
if (radiogroup.getValue() == _root.correctanswer[_root.k]) {
myColour = new Color(_root[“mystate”+_root.k]);
myColour.setRGB(_root.maincolor);
removeMovieClip(_root.question);
_root.total = _root.total+1;
_root.totalquestions = _root.totalquestions+1;
} else {
myColour = new Color(_root[“mystate”+_root.k]);
myColour.setRGB(_root.wronganswercolour);
wronganswercolour;
removeMovieClip(_root.question);
_root.totalquestions = _root.totalquestions+1;
}
}
But I tried changing the zero’s in the lines of code highlighted in red, that did not helped. I thought maybe for some reason the pressed array needed to start with a variable of 19 rather than 0. Not it.
The only other spot it seems to make sense is in the script which loads the questions and answers…
for (var i = 19; i<48; i++) {
questions.push(“This is question”+i);
correctanswer.push("answerA "+i);
myA = ["answerA "+i, "answerB "+i, "answerC "+i, "answerD "+i];
answers.push(myA);
this[“mystate”+i].ivar = i-19;
this[“mystate”+i].onRollover = function() {
this._alpha = 30;
};
this[“mystate”+i].onRollout = function() {
this._alpha = 100;
};
this[“mystate”+i].onPress = function() {
this._alpha = 100;
this.onRollOver = undefined;
this.onPress = undefined;
pressedArray.push(this);
myclip = _root.attachMovie(“mystatequestion”, “question”, i+10);
myclip.myText.text = questions[this.ivar];
//the following lines are for the benefit of your components
//may be a better way
_root.k = this.ivar;
comp0var = answers[this.ivar][0];
comp1var = answers[this.ivar][1];
comp2var = answers[this.ivar][2];
comp3var = answers[this.ivar][3];
trace(comp3var);
question._x = 168;
question._y = 177;
for (var n = 19; n<48; n++) {
this._parent[“mystate”+n].enabled = false;
}
};
}
So I tried adding in the -19 to all places where i is referenced, but that just disables all the state movie clips. I know I should keep testing and come to the answer myself but I was feeling frustrated so I thought maybe writing this out would help me come to some understanding of this, so thanks for listening. Again…and again…