1 person found this helpful
Your description and snippets give only a few pieces of the whole puzzle
var FinalScoreHolder = carla_count + bernice_count + alex_count;
This should not be summed up in compositionReady but after navigating through the quizz ?
Using the var keyword you declare local variables. Duplicating the code "on each of my [your] buttons", you duplicate local variables with the same name !
I guess you need global variables, defined in the stage symbol, in the compositionReady event handler and may be assigned in other symbols.
1) Look at the sym.setVariable() and sym.getVariable() methods in the API :
jim : 0,
laura : 0,
Then elsewhere (inside any symbol) : scores.laura += 5; to increase by 5 this score.
Thanks for your response.
Perhaps you could help me a little more...
alex_count = sym.getVariable("alex_count");
bernice_count = sym.getVariable("bernice_count");
carla_count = sym.getVariable("carla_count");
FinalScoreHolder = sym.getVariable("FinalScoreHolder");
sym.$("alex_count").html("ALEX: "+alex_count+"/2 reviewer points earned");
sym.$("bernice_count").html("BERNICE: "+bernice_count+"/2 reviewer points earned");
sym.$("carla_count").html("CARLA: "+carla_count+"/2 reviewer points earned");
sym.$("grade").html("Total Score: "+FinalScoreHolder+"/6");
This is my updated code on the stage. I want the variables and total to display 0 first as they have the option to click the button at any time, and could click it before having any updated scores, so it should reflect a 0 starting point. I have tried to place the FinalScoreHolder variable on a trigger that occurs at the start of the results portion of the timeline, but it does not seem to affect the stage whatsoever and produces an error. It only displays the proper number when I place it at compositionReady. Do you have any thoughts?
I have changed all of the variables to the method you suggested and as of right now, they all display on the results page as they are coded there, but I'm still having trouble with the updating through the button clicks. What is the proper way to update the variable when using the setVariable/getVariable methods?
This is what I had tried.... just a typical variable declaration.
I alerted the number to check, and it is at 91. I also alerted the variable on the next screen, which also displayed 91. I placed an additional alert on the report screen which also showed 91 which is good... BUT I'm not sure what I'm doing wrong, as the number displayed on the report screen text is still 0... so obviously there is a discrepency between the variables and the button click is not updating the original variable.
My issue is that the user is able to go through the simulation as many times as they would like, and the score should override itself. If the score was constantly updated +1 (or any other number), it would exceed the 2 point max if the user went through it again and again. The score should replace itself, which is why I had just set the variable again on the buttons, and not used any counting/addition techniques.
Thanks for your time again.
Sorry, nshebroe, but despite your detailled description, it's impossible for me to figure out what you have in your mind.
It's not only a matter of syntax, but also a matter of where you place those snippets of code, which are out of context in your post
I suggest you Save as a simplified (and commented) version of your project in another folder, zip that folder, upload the archive to a dropbox and send me the link where a can download.
Then I will look at your source file and provide feedback.
Yeah, sorry about that!
Thanks so much again... Here is my file for you to download: https://www.dropbox.com/s/itn1rvl1ah1db7a/unit3_help.zip
The parts to pay attention to:
- The code on the stage, with the snippets that I have already written above
- the code on the buttons that are labeled as "mix_btn" "qual_btn" and "quan_btn" - the code that I was working on changing is located in the "mix_btn" actions
- The final label on the timeline labeled "report" - which shows the animation/screen for the scores to come up
- The button in the lower right corner of the "home page" is the one to click to bring up the report
- Click on an instructor to start and then choose one of the 3 buttons
- Click the conference button in the lower left corner to return to the "home page"
Nice and sophisticated composition
I will dive into the source as soon as I find time to.
• Stage > counter.click :
var counter = sym.getVariable("counter");
Preceding counter with the var keyword, this variable is local to the event handler.
• Stage > mix_btn.click :
Without the var keyword, the alex_count is global, more precisely accessible anywhere in the symbol (Stage).
• sym.getVariable("alex_count", 12); is the statement to use to assign 12 to the variable alex_count, in case you want it to be accessible in another symbol.
sym.setVariable ("currentLabel"); is a false statement,
as is alex_count = sym.getVariable("alex_count");.
I suggest you read the following thread to clarify the methodology with global variables :
I did not get into the details of your timeline, which is fairly complex, but as far as I understand everything about counting happens inside the Stage symbol. So following this schema will fit :
1) Stage.compositionReady event handler :
alex_count = 0;
2) Stage.trigger at the end of a sequence when Alex makes points
alex_count += 10;
3) Stage.trigger at label report
My eternal gratitude as I have finally figured it out. Thanks so much for your time and help!
Thank you for your gratitude. I am glad if it's now clear in your mind