Thank you!
Glad it helped, I am a little drunk at the moment (holiday here) so just relieved it was quite an easy question.
I do see how this is working, it is defining the array starting with mystate30 and pushing a new value into the array each time (by adding an increment) up to 49. The problem with this is I would either have to label my states that I want the color chosen for as 30-49, or actually define the array with how I have the states already named. The numbers are not in order because of my current labeling system which is alphabetical order. Maybe I should consider grouping them according to how they are being used rather than just simple alphabetical order.
L Well I hope you are enjoying yourself. I would much rather be drinking than attempting this…or at least drinking while I attempting it, though I am already confused as it is.
Have fun!
ps Out of curiousity…Summer Bank Holiday? What does it represent?
no idea at all, sorry.I was desperately searching with google to try find out(trying to appear a little knowledgeable) but failed.
:lol:
That’s quite alright, like I said I was just curious. Your Flash Scripting knowledge quite makes up for having to appear knowledgeable on the significance of British Holidays.
Well I am trying to think of the best way to introduce the opponents states into the game. By this I mean when am I am going to have the 20 states that are the opponents color show up in that color.
I was in the midst of making a new button (called proceed) that shows up once the person enters their name and selects their color, but if I approach it that way, it means I should probably disabled all the states until that proceed button is clicked, the proceed button triggers the script that defines those states and changes them to the color I set.
That might be the hard way though. Maybe I should just preface the game (in the instructions) with the fact that the opponents states will already be set in one color, and just set that color at the begginning without any buttons triggering the event. That’s probably easier.
It gets hard to think all this out because I am not sure how doing this is going to effect everything else that is going on or how I am going to make it work with all else that is going on. Yikes.
Thanks for listening.
or perhaps when a player selects their colour
Have you tried to load one of your fancy graphic swf`s in yet just to check if its going to work?
No I have not gotten that far yet (loading in one of the fancy swfs)
I thought about having the opponents state color change when the user chooses their color, but I thought that could be confusing to the user.
There has to be an explanation at some point anyway, so I guess it is just as well that it would be explained and then just start out that way (with those 20 states already set in the opponents color)
So, I am using your way of defining the array:
[SIZE=1]//setting color of opponents states
for (var t = 19; t<38; t++) {
myOpponentsArray.push(this[“mystate”+t]);
}[/SIZE]
And am testing things out to see what my next step is. I think I set the loop like this: [SIZE=1]for (var u = 0; u<myOpponentsArray.length; u++)[/SIZE]
and then somehow have a function that sets the rgb of those states but I don’t know how or if I need something to set it off
[SIZE=1]for (var u = 0; u<myOpponentsArray.length; u++) {
myOpponentsArray[u][“myColour”+u] = new Color(myOpponentsArray[u]);
myOpponentsArray[u].col = myOpponentsArray[u][“myColour”+u].setRGB(0x003366);
}[/SIZE]
maybe? I am trying to look at what you have already provided and make it work for this, I am actually right in the middle of trying to do this
Can you tell me what you see wrong with this?
[SIZE=1]//setting color of opponents states
for (var t = 19; t<38; t++) {
myOpponentsArray.push(this[“mystate”+t]);
}
myOpponentsArray[u].onLoad = function() {
for (var u = 0; u<myOpponentsArray.length; u++) {
myOpponentsArray[u].myColor = new Color(myOpponentsArray[u]);
myOpponentsArray[u].myColor.setRGB(0x003366);
}
};[/SIZE]
Because it’s not doing anything. I will figure it out eventually though…have a good night and enjoy the rest of your day off.
myOpponentsArray[u].onLoad…
u is not yet defined
Try doing away with the onload thing altogether.
for (var u = 0; u<myOpponentsArray.length; u++) {
myOpponentsArray[u].myColor = new Color(myOpponentsArray[u]);
myOpponentsArray[u].myColor.setRGB(0x003366);
}
make sure your array is defined before this
myOpponentsArray[u].onLoad…
u is not yet defined
Try doing away with the onload thing altogether.
for (var u = 0; u<myOpponentsArray.length; u++) {
myOpponentsArray[u].myColor = new Color(myOpponentsArray[u]);
myOpponentsArray[u].myColor.setRGB(0x003366);
}
make sure your array is defined before this
myOpponentsArray = []
I need to be slapped :trout:
Was also not thinking correctly about the u variable…thanks again!!
Hmmm…just wondering which one of us was drunk
I can assure you that I can barely handle this sober
Is this a logical conclusion…or should I say am I right on this…
In the loop that defines the array which holds the user’s states (the states that change color when one of the color buttons is selected) the variable is set to start with zero, adding an increment until it reaches 18.
[SIZE=1]for (var s = 0; s<19; s++) {
myArray.push(this[“mystate”+s]);
}[/SIZE]
Which does turn the states that are labeled 0 through 18 whatever color is selected.
Therefore, when I am trying to make a certain question load when a certain state is clicked, couldn’t I conclude that I could set the loop like this:
[SIZE=1]for (var i = 19; i<48; i++) [/SIZE]
and it would “hold” the questions for 19 through 47 in the array that it is referencing?
I might be jumping the gun and asking this too fast after not enough studying of how your last example was set up…because yours was working correctly and coordinated the correct question with the correct state. I was trying to replace what you provided (below) with actual questions & answers.
[SIZE=1]//in the following, i have just looped through to give values to questions answers etc
//when you come to make it properly, you can take there out of the loop and just type
//them in as we did before
//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++) {
//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 = 0; n<48; n++) {
//this._parent[“mystate”+n].enabled = false;
//}
//};
//}[/SIZE]
I replaced all that with this (and I took out the question, answer, and correctanswer array definitions that were at the beginning cause they are defined here, so I am paying attention to your lessons )
[SIZE=1]questions = [“19”, “20”, “21”, “22”, “23”, “24”, “25”, “26”, “27”];
answers = [[“19”, “19”, “19”, “19”], [“20”, “20”, “20”, “20”], [“21”, “21”, “21”, “21”], [“22”, “22”, “22”, “22”], [“23”, “23”, “23”, “23”], [“24”, “24”, “24”, “24”], [“25”, “25”, “25”, “25”], [“26”, “26”, “26”, “26”], [“27”, “27”, “27”, “27”]];
correctanswer = [“19”, “20”, “21”, “22”, “23”, “24”, “25”, “26”, “27”];
//number of states here
for (var i = 19; i<48; i++) {
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
comp19var = answers[this.ivar][0];
comp20var = answers[this.ivar][1];
comp21var = answers[this.ivar][2];
comp22var = answers[this.ivar][3];
comp23var = answers[this.ivar][4];
comp24var = answers[this.ivar][5];
comp25var = answers[this.ivar][6];
comp26var = answers[this.ivar][7];
comp27var = answers[this.ivar][8];
question._x = 400;
question._y = 400;
for (var n = 19; n<48; n++) {
this._parent[“mystate”+n].enabled = false;
}
};
}[/SIZE]
I also changed the setLabels for the radio buttons in the question movie clip:
[SIZE=1]comp19.setLabel(_root.comp19var);
comp20.setLabel(_root.comp20var);
comp21.setLabel(_root.comp21var);
comp22.setLabel(_root.comp22var);
comp23.setLabel(_root.comp23var);
comp24.setLabel(_root.comp24var);
comp25.setLabel(_root.comp25var);
comp26.setLabel(_root.comp26var);
comp27.setLabel(_root.comp27var);
comp28.setLabel(_root.comp28var);[/SIZE]
Doing all this thinking this is how I will get it to coordinate with each state that would be that number: comp19 part of question 19 that is loaded when state 19 is clicked?
This seems to be a major bit which you are not understanding properly.
//myA = ["answerA "+i, "answerB "+i, "answerC "+i, "answerD "+i];
//answers.push(myA);
this make answers an array of arrays
so answer[0]=["answerA "+0, "answerB "+0, "answerC "+0, "answerD "+0];
and answer[0][0]="answerA "+0
answer[0][3]="answerD "+0
so using our ivar we can find any answer
//comp0var = answers[this.ivar][0];
//comp1var = answers[this.ivar][1];
//comp2var = answers[this.ivar][2];
//comp3var = answers[this.ivar][3];
we only need four variables corresponding to a,b,c,d
and on the radio buttons
comp0.setLabel(_root.comp0var);
comp1.setLabel(_root.comp1var);
comp2.setLabel(_root.comp2var);
comp3.setLabel(_root.comp3var);
although like i said before, i don`t normally use the MM components so there may be a better way to do this.
You are correct, I was not understanding that properly. I think I actually need to take some more time and really force myself to go through and analyze the steps of how this is working before I attempt to change things. I should know that by now, shame on me.
So that is what I will do.
:tb: i’m back!
I am just starting to work my way through this script and make myself understand what is going on. Small thing here, but I would like to know.
Is this [SIZE=1][“color”+c][/SIZE] an array?
in this block of code:
[SIZE=1]for (var c = 0; c<5; c++) {
this[“color”+c]._visible = false;
}[/SIZE]
I think it has to be, it defines each color button (0-4) but what I don’t understand is how it could work without being defined earlier, but maybe I am just assuming that because of the [] it is an array…
The only placed we referenced those color buttons prior to that code is here:
color0.col = 0x990000;
color1.col = 0x9966CC;
color2.col = 0xFFFF99;
color3.col = 0x9999FF;
color4.col = 0xFF9900;
I see that it is just being used to hide all the buttons. Just not completely sure why it is working.