-
1. Re: Point system? Help with variables.
AMULI Sep 3, 2013 8:25 AM (in response to nshebroe)Hi nshebroe,
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 :
http://www.adobe.com/devnet-docs//edgeanimate/api/current/index.html#symbolinstance
2) Or use a JavaScript object, initialized in the compositionReady event handler :
scores =
{
jim : 0,
laura : 0,
ben: 0
};
Then elsewhere (inside any symbol) : scores.laura += 5; to increase by 5 this score.
Gil
-
2. Re: Point system? Help with variables.
AMULI Sep 3, 2013 8:35 AM (in response to nshebroe)More on global variables here (with an example to download) :
http://forums.adobe.com/message/5512963#5512963
Gil
-
3. Re: Point system? Help with variables.
nshebroe Sep 3, 2013 9:47 AM (in response to AMULI)Hello,
Thanks for your response.
Perhaps you could help me a little more...
sym.setVariable("alex_count", 0);
sym.setVariable("bernice_count", 0);
sym.setVariable("carla_count", 0);
alex_count = sym.getVariable("alex_count");
bernice_count = sym.getVariable("bernice_count");
carla_count = sym.getVariable("carla_count");
sym.setVariable("FinalScoreHolder", carla_count+alex_count+bernice_count);FinalScoreHolder = sym.getVariable("FinalScoreHolder");
//alert(alex_count);
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.
if(currentLabel=="alex1"){
alex_count=91;
//alert(alex_count);
sym.play("alex_mix");
}
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.
-
4. Re: Point system? Help with variables.
AMULI Sep 3, 2013 10:40 AM (in response to nshebroe)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.
Gil
-
5. Re: Point system? Help with variables.
nshebroe Sep 3, 2013 11:00 AM (in response to AMULI)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"
-
6. Re: Point system? Help with variables.
AMULI Sep 3, 2013 12:10 PM (in response to nshebroe)Nice and sophisticated composition
I will dive into the source as soon as I find time to.
Gil
-
7. Re: Point system? Help with variables.
AMULI Sep 4, 2013 1:08 PM (in response to nshebroe)Hi nshebroe,
• Stage > counter.click :
var counter = sym.getVariable("counter");
counter++;
sym.$("counter").html(counter);
sym.setVariable("counter", counter);
Preceding counter with the var keyword, this variable is local to the event handler.
• Stage > mix_btn.click :
if(currentLabel=="alex1")
{
alex_count=91;
sym.play("alex_mix");
}
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 :
http://forums.adobe.com/thread/1288441?tstart=0
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
sym.$("total_alex").html( alex_count);
Gil
-
8. Re: Point system? Help with variables.
nshebroe Sep 4, 2013 2:09 PM (in response to AMULI)My eternal gratitude as I have finally figured it out. Thanks so much for your time and help!
-
9. Re: Point system? Help with variables.
AMULI Sep 4, 2013 2:30 PM (in response to nshebroe)Thank you for your gratitude. I am glad if it's now clear in your mind
Gil

