Graph Opinion

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…

yeh its really confused things swapping the numbers round
change the code on mystatequestion to
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 = 38; i<48; 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+38)]);
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+38)]);
myColour.setRGB(_root.wronganswercolour);
removeMovieClip(_root.question);
_root.totalquestions = _root.totalquestions+1;
}
}

and cross your fingers
if i get time tomorrow,i`ll try restructure it a little.(Although maybe it is better to leave it as it is if you eare beginning to understand.)

“cross your fingers”…I have such faith in you but sounds like you doubted yourself a little…L

It worked perfectly of course, only thing is instead of 38, I put in 19 because the user is allowed to choose from either the opponent’s states, which are 19-38, or the undecided states, which are 38-47, so they can choose from var i = 19; i<48;

Let me ask your advice on this…I am going to have a slightly different reaction if the user gets a correct answer when the opponent’s state is chosen rather than when an undecided state is chosen. I think that I can just add an “else if” to the script on the myState movie clip, but I will figure that part out…I think I can, I think I can…

Anyway, what I wanted advice on is do you think I should get that working before I try and plug in actual questions and answers? I probably should.

You know, you should really be a Flash teacher. Not just on the forums, but professionally.

yes I think you probably should too.
teachers are underpaid/undervalued in the uk.
Might also be worth trying to load in one of your fancy graphics before finalising anything.

“teachers are underpaid/undervalued in the uk.”

Well, that’s the same here. It’s just too bad because you really are very knowledgeable and patient.

Alright, I have been working on figuring out the graph to act as the question gage, but I keep getting rudely interrupted with other work projects…the nerve I tell you :tb:

So, I will get back to that when I can and yes I will try loading in the fancy graphics to see how that goes as well.

Thanks!

Well I have been thinking out the best way to do this graph set up that I want to use, and I started out figuring that I want to graph to increase by 475/10 each time someone gets an answer right. Well before I even get that far I think, I need to figure out how to motion tween something using as instead of on its timeline, as use this as my increment of how much it should increase each time a question is correct.

Well anyway to make my long explanation short, I am having a hard time finding any examples, tutorials, threads or anything anywhere that would give me a clue how to do this.

Do you know how and if you have time is there anyway you could show me a basic example of tweening something with as? Or maybe you know of a tutorial or thread that already exists on this. I want to figure this out without being told exactly what to do …I feel as though I am getting no where. A lot of the things I have found related say look up easing but that is not helping much either.

A couple of ways of doing it here.Hope they help

Well, well, well…talk about fancy graphics! That’s a hell of a fancy bar graph you provided there :wink: Very nice!

It works wonderfully, and of course seems to involve much more than I anticipated.

Well I reversed your growTo function, calling it shrinkTo, (for barthing) in hopes of getting the opposite reaction when a different button is pressed. (In order to shrink the user’s graph when they get a question wrong)

Shocking, but it worked. (Shocking only because of my involvement with it)
Only thing is, it just drops down rather than tweens down. I am going to post the fla, but I will continue to take a look at it to see if I can figure it out on my own.

EDIT:
well I guess it was too shocking…it works as long as the first choice is not wrong, in other words in this example, if fbutton is not clicked first. I think I spoke way too soon…

Not at all,I found it in the midst of my “Rather plain bar chart collection”. :liar:

:sure:

You actually only need the one function
barthing._height = 0;
growTo = function (clip, h, step) {
hButton.enabled = false;
fButton.enabled = false;
clip.targetheight = h+step;
clip._height += (clip.targetheight-clip._height)/10;
if (Math.abs(clip.targetheight-clip._height)<1) {
clip._height = clip.targetheight;
clearinterval(hinterval);
hButton.enabled = true;
fButton.enabled = true;
trace(barthing._height);
}
};
hButton.onPress = function() {
hinterval = setInterval(growTo, 20, barthing, barthing._height, 475/10);
};
fButton.onPress = function() {
hinterval = setInterval(growTo, 20, barthing, barthing._height, -475/10);
};

i only included the enabled bits because it can break down if you click quickly,but you won`t need them when you make your final chart.

So you have combined it all in one function, of course it makes so much sense after you do it! :beam:

Would it have worked the way I was trying to make it work if I would have set the shrinkTo function with an if statement that said only if the height of barthing is greater than zero and less than 475? Not that it really matters, I was just trying to think of solutions.

shrinkTo = function (clip, f) {
clip.targetheight = f-475/10;
trace(clip.targetheight);
clip._height += (clip.targetheight-f)/10;
if (Math.abs(clip.targetheight-clip._height)<1) {
clip._height = clip.targetheight;
clearinterval(finterval);
trace(barthing._height);
}
};

Stringy if I have a block of code, such as below, and I want to add another “if” action to it, what would be the best way to do so? It needs to be part of the loop, and I have already tested with a very simple action (I made a movie clip on the main timeline and set the height of that mc when the correct answer was selected). It throws me off once things get more complicated, as in, I don’t see if I should set up a completely new loop with conditions or do I add new conditions into what already exists?
Maybe (going over previous examples from you) it could or should all be written into one block or function, but that might get tricky as I am going to have at least 3 things happen dependent upon what answer the person chooses.

for (var i = 19; i<48; 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+19)]);
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+19)]);
myColour.setRGB(_root.wronganswercolour);
removeMovieClip(_root.question);
_root.totalquestions = _root.totalquestions+1;
}
}

Depends what you are trying to do.
Basically the code says
if correct-dosomestuff
else(so incorrect)-do dome otherstuff

so if you wanted to add a condition knowing that the answer was correct you would add within the first if or if you wanted to add something knowing the answer was wrong within the else.
eg/
if (radiogroup.getValue() == _root.correctanswer[_root.k]) {
if (something == 1) {
//new if
dosomething;
} else {
//new else(maybe else if)
myColour = new Color(_root[“mystate”+(_root.k+19)]);
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+19)]);
myColour.setRGB(_root.wronganswercolour);
removeMovieClip(_root.question);
_root.totalquestions = _root.totalquestions+1;
}

A little difficult to explain

What I am wanting is to do more than one thing when the “if” condition is met.

Like this:
if (radiogroup.getValue() == _root.correctanswer[_root.k]) {
dosomething;
doadifferentsomething;
doyetanotherdifferentsomething;
}

I just don’t think that is the right way to set it up when the “do somethings” are more complicated.

I don’t know how to seperate it. These are simple because each one is short and takes up less than a line to get the result you want. When you get into a more complicated formula, do you still just use only the semicolons to signify the end of a line or are curly brackets or brackets needed?

You know what, I apologize for going on about this. What I need to do is just try it and see. I get a little intimidated by this at times as I have never done anything quite at this level before.

Thank you!!

No,unless you have if,for etc you are not going to need {}
try
trace(“dosomething”);
trace(“doadifferentsomething”);
trace(“doyetanotherdifferentsomething”);
inside the function

Yes I do see that very well. It returns all three “somethings” no problem.

I forsee problems when my something is more complicated such as the code for the bargraph…goes up when the answer is correct, down when the answer is wrong. Plus the opponents will go up and down as well.

But maybe that is a case where the function is defined in a different place, (such as below all this code) you just call the function from the if statement.

Right now I am working on loading the fancy swf’s into my main movie and hiding them until needed like you suggested.

At least I have plenty to do, when I get frustrated with one thing I can work on something else and come back to it later.

all you need do is call the function with a path to the function
from the question thing use
if (radiogroup.getValue() == _root.correctanswer[_root.k]) {
this._parent.myfunction(parameters);

same as typing myfunction(parameters) on the _root timeline.
try keep as much code on the main timeline as you can.

I`ve waited so long to see your fancy graphics