Graph Opinion

wlecome back
It actually refers to the buttons but you are not wrong in thinking of it as an array.(each timeline has a special sort of array called an associative array which contains the names of all the clips)
so the “this” says to look on this timeline and the bit in brackets what to look for
this.color0._visible = false
this.color1._visible = false
etc

you could replace “this” with _root and it would still work but if you had a change of plan (as if!!!) and decided to load this swf into another then _root would fail as flash would be looking for instance names color0 etc on the main timeline (now _root) of the swf this was loaded into.

:nerd: I see! Thank you. I was getting a little confused by the “this” in this case. Good call, cause yes imagine that, that I may have to change something

Onward with the translation then…

Could you please explain the “ivar” used here?

[SIZE=1]this[“mystate”+i].ivar = i;
this[“mystate”+i].onRollover = function() {
this._alpha = 30;
};[/SIZE]

I know it is targeting one of of the state movieclips, whichever one it happens to be on at this point, like myState3 for example, and I know it has something to do with a variable that has been or is being created, but I am losing the connection after that.

it should be in a for loop and targeting all the state mcs you need. The ivar gives each mc a unique property which you can use for all sorts but which we have mainly been using to reference elements in an array. myState0 will have an ivar of 0 etc. I cant remember the array names etc we used but for you to understand try typing something like
myState0.onRelease = function(){
trace(myArray[this.ivar]);
}
this should give you myArray[0]
we then put this into a loop so every mc has unique array elements which it can refer to.
we have used this.ivar inside the function because “this” inside callback functions refers to the object which is using the function not to the timeline.
A little confusing at first but makes sense really.

okay, so very basically it is giving a numeric (ordered) value to each state in the array, right?

Like saying, “The value of myState0 is zero.” or “The value of myState31 is thirty-one.”

Right?

And that allows each mc in the array to have unique elements, which we would need to do because not all of them will have the same things happen to each of them? I mean does this allow for different reactions to be applied to each clip depending on what answer is chosen…I guess I don’t understand why it needs to be unique.

Oh, and yes it is used with a for loop, earlier on:
[SIZE=1]for (var i = 0; i<30; i++)[/SIZE]

As I reread your last post,

“The ivar gives each mc a unique property which you can use for all sorts but which we have mainly been using to reference elements in an array.”

We need the ivar to allow us to reference each statemc separately rather than the entire array at once?

This is how we make the questions/answers link up with each mc.In other words how each state knows how to find questions/answers for that state.

oh! Well good because that is one of the things that I have really been wondering about. I love it when this starts making sense. :thumb:

Again, thank you for your patience with me on this!

you are welcome but i`m thinking about applying to be a saint.

LOL you already are in my eyes!

Is what I have commented below correct? Because I think I might be confusing what happens with the [SIZE=1]pressedArray.push(this); [/SIZE] with what happens here: [SIZE=1]myclip.myText.text = questions[this.ivar];[/SIZE]

[SIZE=1]this[“mystate”+i].onPress = function() {
this._alpha = 100;
this.onRollOver = undefined;
this.onPress = undefined;[/SIZE]
//“pushing” the pressed array is the way of getting the right question
//to come up for the state that has been clicked?
//it returns the number of the state that has been clicked that question
//can be pulled from the question array?
[SIZE=1]pressedArray.push(this);
myclip = _root.attachMovie(“mystatequestion”, “question”, i+10);
myclip.myText.text = questions[this.ivar];[/SIZE]

if i remember correctly, pressedArray just contains the states which have been pressed. when you push something into an array all you are doing is adding another element to the end of that array.If we know all the states which have been pressed, we can diable them whenever.

You do remember correctly. The “mystatequestion” mc, which holds this code:

[SIZE=1]comp0.setLabel(_root.comp0var);
comp1.setLabel(_root.comp1var);
comp2.setLabel(_root.comp2var);
comp3.setLabel(_root.comp3var);
function checkradio() {
trace(radiogroup.getValue());
for (var i = 0; i<30; i++) {
_root[“mystate”+i].enabled = true;
}
for (var j = 0; j<_root.pressedArray.length; j++) {
_root.pressedArray[0].enabled = false;
}
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;
}
}[/SIZE]

Refers to the pressed array. I don’t know how much more I will be able to pursue this today and follow it well (not that I am anyway) as I had a couple of drinks with my lunch…so I am a bit fuzzy…and wish that I could just lay my head down onmy desk and take a little nap. :snooze:

for (var i = 0; i<30; i++) {
_root[“mystate”+i].enabled = true;
}
for (var j = 0; j<_root.pressedArray.length; j++) {
_root.pressedArray[0].enabled = false;
}
I think prior to this we have already diasabled everything.(main timeline)

what we do here is enable everything but then straight away disable the buttons which have already been pressed so they can`t be used again.Becuse it is so quick it is not possible to tell and we are left with just the buttons which have not yet been pressed still enabled.
Drinking at work, thats terrible.

well work is the one who provided it for me so it’s actually not that terrible :smirk: …just makes you have no motivation for getting back to work…

I do follow what you have explained. I have a meeting to go to so my studies are once again interrupted. I do have a goal of having this part all figured out by the end of the day on Tuesday though…we have a long weekend here so there is no work on Monday. Kind of like your summer bank holiday I think, but I am going to try and work with it on my own time if I can manage.

So, Saint Stringy, until I am back to pester you with more questions, I leave you in peace…

I have gone through and commented the code in the working file that you provided last. This is here along with the file I started modifying to do the additional things I need to do. Your file is called maptest_workingquestions and the modified files is called maptest_withinterface&questions.

So, far the changes that I made were to group the states in a numerical order that also corresponds to how they are being used:

states 0-18 are the user’s states
states 19-37 are the opponent’s states
states 38-47 are the undecided states

The opponents states are set to be a certain color when the movie is played, the user chooses a color for his or her states and they are disabled.

What I am currently having a problem with is finding where the parameters for a question being loaded is set. I do know that this code here:

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;
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 = 400;
question._y = 400;
for (var n = 19; n<48; n++) {
this._parent[“mystate”+n].enabled = false;
}
};
}

Is all used to coordinate which question goes with which state, etc. But I don’t see a limit to how many questions should be loaded. I am tracing undefined in the output box when I click on many of the states. It seems to me that as long as a state is enabled, which all of the opponent and undecided states are (until clicked on) a question should be loaded…here for testing purposes it just is basically loading a number. (This is question44, etc)
I get results for some, some return undefined. I don’t know why.

I feel as though I need to understand why this is not working before I proceed to define actual questions and answers.

You need to redifine each states ivar
this[“mystate”+i].ivar = i-38;
and use for (var i = 38; i<48; i++) {…
because we are trying to use the ivar to find things in arrays.
first element in (any) array is array[0]
if we did not change state38 would have an ivar of 38 and is looking for array[38] which is not going to work.
Hope you understand

Oh my I really don’t think I would have ever figured that one out. I actually want them to be able to select from states 19 through 47, rather than 38 through 47 so I changed it to:

[SIZE=1]this[“mystate”+i].ivar = i-19;[/SIZE]

I had already set the preceding loop to this:

[SIZE=1]for (var i = 19; i<48; i++)[/SIZE]

so in the [SIZE=1]this[“mystate”+i].ivar = i-19; [/SIZE] line of script adding the -19 is simply stating to start numbering the ivar value at 19 rather than at 0 like it was?

I was confusing it, (it being Flash) because I was clicking on a state and it could not find the correct question (in the array) to coordinate with because I had it starting at zero and counting up from there. Right?

At least I can understand my mistakes!

Yeh you were confusing “it” and me.
so basically you want state19.ivar = 0, state20.ivar =1 etc.

Well at least I’m good at something :wink: