I feel like this is fast/easy to solve, but I'm stuck AS 3 problem

I thought I'd teach my grade 10 programming class Action Scripting 3.0. We've already gone through SmallBasic and they understand conditional logic, looping etc.. to give you a bit of background so I thought we'd tackle it in an OOP language.
I haven't tackled A.S. since back in 2.0 and I think maybe I'm missing something. I used this tutorial as a foundation and updated it to reflect AS3.0 for my course notes.
That said, when making their quiz, (a simple 2 question quiz that tallies the score at the end of the quiz) I keep getting a logic error. Everything runs smoothly using the controls, I'm getting the variables return properly to the Interpreter pane, but the logic evaluation at the end returns a glitch where it counts against my last clicked value and uses it twice to evaluate truth. Likely I'm missing something simple and it'll take somebody who knows Flash well about 3 seconds to ID my problem.
Thanks in advance.
FLA file if you want to browse it:
FLA file
SWF file if you want to view that:
SWF file
If you don't want to dload the files then here's AS code at the 3 locations (q1, q2, quizEnd)
Code Block 1 at frame 1:
// Initialize main timeline variables
// next, create variables to store user's answers:
var q1Answer;          // User's answer for question 1
var q2Answer;          // User's answer for question 2
//next, create a variable to track number of questions answered correctly:
var totalCorrect = 0;  // Counts number of correct answers
//finally, stop the movie at the first question:
stop();
choice1_btn.addEventListener(MouseEvent.CLICK, answer1);
function answer1(event_object:MouseEvent){
q1Answer = 1;
gotoAndStop("q2");
trace(q1Answer);
choice2_btn.addEventListener(MouseEvent.CLICK, answer2);
function answer2(event_object:MouseEvent){
q1Answer = 2;
gotoAndStop("q2");
trace(q1Answer);
choice3_btn.addEventListener(MouseEvent.CLICK, answer3);
function answer3(event_object:MouseEvent){
q1Answer = 3;
gotoAndStop("q2");
trace(q1Answer);
Code Block 2 at frame 10
choice1_btn.addEventListener(MouseEvent.CLICK, answer21);
function answer21(event_object:MouseEvent){
q2Answer = 1;
gotoAndStop("quizEnd");
trace(q2Answer);
choice2_btn.addEventListener(MouseEvent.CLICK,answer22);
function answer22(event_object:MouseEvent){
q2Answer = 2;
gotoAndStop("quizEnd");
trace(q2Answer);
choice3_btn.addEventListener(MouseEvent.CLICK,answer23);
function answer23(event_object:MouseEvent){
q2Answer = 3;
gotoAndStop("quizEnd");
trace(q2Answer);
Code Block 3 at frame 20
if (q1Answer ==  3) {
  totalCorrect = totalCorrect + 1;
  trace("Value for Q1 is 1 point");
  } else {
          trace("Wrong answer #1 " + q1Answer);
if (q2Answer == 3) {
          totalCorrect++; //simply adds 1 more to the previous value of totalCorrect//
          trace("Value for Q2 is 1 point");
} else {
              trace("Wrong answer #2 " + q2Answer);
//displays final score on interpreter
trace("Your total is "+totalCorrect+"/2 points");
//displays the answer on the stage
var txtFld:TextField = new TextField();
addChild(txtFld);
txtFld.text = ("Your total is" + totalCorrect);
txtFld.appendText ("/2 points");
//extra bits to un-comment once text output is understood
//txtFld.wordWrap = true;
//txtFld.textColor = 0xFF00FF
//txtFld.width=150
//txtFld.height = 60

Let's say I click on button1 at frame 1 returning a value for q1Answer as 1, then button 3 at frame 10 returning a value for q2Answer as 3, I'll get both questions marked as right. Button 3 is the "right button" in each case so only q1Answer = 3 and q2Answer=3 should be correct.
Here's the trace output if I click as above:
1
3
Value for Q1 is 1 point
Value for Q2 is 1 point
Your total is 2/2 points
3
If I click on 1 and 2 say instead, here's the Interpreter result:
1
2
Wrong answer #1 2
Wrong answer #2 2
Your total is 0/2 points
2
Mystifying.
kglad wrote:
looks ok.
which trace is giving an unexpected result?

Similar Messages

  • Recently, after cancelling the tick of a song, which is the next song after the one I am listening, in the song list, the canceled song will still run for the next song. I remember that it used not to happen like this. How can I solve this problem?

    Recently, after cancelling the tick of a song, which is the next song after the one I am listening, in the song list, the canceled song will still run for the next song. I remember that it used not to happen like this. How can I solve this problem?

    This looks like a change of behaviour in iTunes 12. Once songs are queued up to the Up Next list then they play whether ticked or not. If you want to skip certain songs already queued click the Up Next tool, then click the small X to the left of the song that appears when you hover over it.
    tt2

  • Anyone else feeling like this is more trouble than it is worth?

    I am currently under the grandfather plan of unlimited data, text with 450 minutes and an employee discount. I have enjoyed the usage of my Droidx for almost 3 years now. It had a good run, but the pinch of an $80 smart phone plan just doesn't seem worth it anymore. To be honest, for me the pricing of cell phone plans is getting out of control. Like everything else it seems, prices have gone up, but per usual, my income has not.
    The share-everything plans look like absolute nightmares and terrible deals, and to switch over would increase my costs by $20 for what I feel is a very bad deal, seeing as I do not use many minutes on my cell phone. Although I take very good care of my phone, I am not naive enough to think that it will last forever. 2GB data plan is hardly what I would call a pot to pee in, especially with e-mail, web, pictures, etc.  I realize the bottom line of the company is to make money, but lately it just seems like all of the hooplah that comes with smartphones is enough to try the patience of any saint. I'm contemplating alternatives, but I am not sure where to start. Perhaps it's time just to go to good old prepaid cell phone, and pretend I never had internet to begin with
    I think the turning point for me today was the phone call I received from Verizon regarding my bills. I've never had a late bill in the 16 years I have been with them, but for some reason, my payment for February did not go through.The first words out of this lady's mouth were "I'm _____ from Verizon Wireless, you owe us ___________ how will you be paying your bill today?" Seriously? First time being late, and even though I have e-mail notifications, this is the crap I am greeted with upon answering the phone. No thank you, kiss my rear, nothing? What am I, chopped liver? Lol.

    It sounds like you've been scammed. Firefox is a completely free browser that doesn't require either payment or registration. Never download it from anywhere but the official site:
    * http://www.mozilla.org/
    Please report the offending site on the page below:
    * http://www.mozilla.org/en-US/legal/fraud-report/
    You'll have to sort out the situation with whoever took your money, or failing that, with your bank or credit card company.

  • HT204088 Why am I being charged three times for an game that I purchased? Plus, there is nothing in your website to address this problem. It makes me feel like this company is just trying to steal my money if I do not look or question my billing account.

    How do I get extra charges credited back to my account? I was over charged three times on an app I bought.

    So any time any company accidentally charges you 2-3 times, they are trying to steal your money? In most cases, they fix it on their own after they catch it. If you want to make them aware of the issue, contact iTunes Support: http://apple.com/support/itunes/contact/

  • When you get a new computer how do I put on my iTunes library - I do have it all backed up to the cloud.  I am not a technical person so this is probably easy for someone but not me!  Any help would be much appreciated

    Can anyone explain what I need to do.  I am buying a new computer, need to de-authorise my old computer and then put the library on a new windows computer.  I have my library backed up to the cloud for which I pay extra.  I am not at all technical so if anyone could give me idiot instructions I would much appreciate it.  Finding the instructions from apple assume I know basic,s and that confuses me!

    Hey Dollydayle,
    The steps in this link can help you with moving your music to your new computer,  with several options you can choose from that best suit your needs:
    iTunes: How to move your music to a new computer
    http://support.apple.com/kb/HT4527
    Welcome to Apple Support Communities!
    All the best,
    Delgadoh

  • A component like this ?

    I want to use a flex  component like that used in this web site
    http://www.ilsole24ore.com/
    On the center on site you can see a javascript script to select one news to another...it's similar to "the cover flow"...
    Where can i found a component like this?
    sorry for my bad english

    Just write own component - something like this is very easy and fast to done.

  • It is possible to create something like this in AE?

    Hi, i want to know if its possible to create something like this in AE (not in 3D) but particles that 'builds up' the text in some way? i have a text that is a vector, and the same as PNG, it is possible? Please tell me!

    It's amazing what Google can find:
    Red Giant - RGTV - Sand to Text Transitions
    Something similar from a zillion years ago:
    Flowing Title Effects using Adobe After Effects : Adobe After Effects Tutorial

  • In XML Forms Date Format want to display like this (dd-MMM-YY)

    Hi All,
    I created one Custom Property for Date and use that property in XML Form Builder. In the RenderList that Date Field Display as (Medium Format) showing like this Apr 21, 2009 Format.
    But i requirement is to display Date Field as like this 21-Apr-2009 (DD-MON-YEAR) Format.
    In the Custom Property i set the
    Additional Metadata (csv): +   customFormat=dd.MMM.yyyy but this way is not working for XML Forms.(Refered this SAP NOTES:816761)
    when the IE Browser language is English(United States) [en-us] Date Field Display as (Medium Format) showing like this Apr 21, 2009 Format.
    But when the IE Browser language is English(canada) [en-ca] Date Field Display as (Medium Format) showing like this 21-Apr-2009 Format. so this way is not a right way..
    I need to achieve this..  please help me.. Appreciate for helpful answer.
    Regards
    Thillai J

    Thillai:
    Refer to this post:
    https://www.sdn.sap.com/irj/scn/thread?messageID=1166540
    Hope this helps!

  • HT5848 Cannot tap "play more like this" or "never play this again"!

    On my iPhone 5 in the iTunes Radio page when I tap on the star I cannot tap the options to "play more like this" or to "never play this again". Is anyone else having this problem/can someone help me out? Thanks!!

    I have this same problem; however, I've always ONLY been able to "play more like this" on the PRESET stations; otherwise, how could you have any 'new music' to select that you may want to hear more songs like the one you just heard and 'play more like this."  If you could only choose your OWN music to "play more like this," it doesn't make sense why you would choose your own music? 
    So, I've been able to choose  "play more like this," ONLY on the preset stations, but sometimes they are grayed out and I cannot select that option.

  • Hi it's me rabia and i'm apple user  I want to change my cell phone because it's having scratches on it and i also feel like its home button did't work correctly  So i want to know that can i have a new cell phone on replace of this one at any nearby of m

    Hi it's me rabia and i'm apple user
    I want to change my cell phone because it's having scratches on it and i also feel like its home button did't work correctly
    So i want to know that can i have a new cell phone on replace of this one at any nearby of my house App store without any cost  ?
    But i'm not having any line yet on my phone i use it on net mostly so what is the scene can i have or can't ??
    please inform me soon !

    Is your phone still covered by warranty?  If so, go to your nearest Apple store and depending on what happened, this may or may not be covered by warranty.  If it is, then you can get a replacement exactly as the phone you already have.
    If out of warranty, then there is nothing you can do and you'll have to pay.

  • My weather app doesn't show the feels like temp or wind, etc.  How can I fix this?  I am running iOS 8.1.2

    My weather app doesn't show the feels like temp or wind, etc.  How can I fix this?  I am running iOS 8.1.2.

    is that really what it is?  this is the native iphone weather app.  the funny part is that when i use the actual weather channel app, it does provide it.
    is this an api issue with the weather channel and the iphone then?  i guess there's no fix?
    thanks for your help by the way.

  • How can someone use a stolen iphone? does erasing the phone (which I feel like I should do) make it easier for the thief to use the iphone?  If I don't erase it, it doesn't seem like anyone should be able to use the phone because of my password.

    how can someone use a stolen iphone? does erasing the phone (which I feel like I should do) make it easier for the thief to use the iphone?  If I don't erase it, it doesn't seem like anyone should be able to use the phone because of my password. Also, is it possible to retrieve anything that has been sent to the phone (i.e. text messages) since it was stolen through icloud? The "find my iphone" app says the device is offline but it rings when I call my number -- any idea how that would be the case? Thanks!!

    You have a password, so good move on your part.  Whether you erase it or the thief does, they still get to use the iPhone as theirs.  Which is more important (pick one), protecting your data or punishing the thief?
    Ringing occurs at the carrier.  Chances are you're going to voicemail after only two or three rings.  If you have an iCloud backup also a good move.  Re-read my question in the first paragraph.

  • After updating my Macbook Pro retina display to os x yosemite 10.10.2, the mause and track pad locks, and do not respond especially when using the Mac for a long period, please help, how can I solve this, I do not like feel like in windows, so I paid

    after updating my Macbook Pro retina display to os x yosemite 10.10.2, the mause and track pad locks, and do not respond especially when using the Mac for a long period, please help, how can I solve this, I do not like feel like in windows, so I paid good money for this mack, I feel calm

    Hi Buterem,
    I'm sorry to hear you are having issues with your MacBook Pro since your recent Yosemite update. I also apologize, I'm a bit unclear on the exact nature of the issue you are describing. If you are having intermittent but persistent responsiveness issues with your mouse or trackpad, you may want to try using Activity Monitor to see if these incidents correspond to occupied system resources, especially system memory or CPU. You may find the following article helpful:
    How to use Activity Monitor - Apple Support
    If the entire system hangs or locks up (for example, if the system clock freezes and stops counting up), you may also be experiencing some variety of Kernel Panic. If that is the case, you may also find this article useful:
    OS X: When your computer spontaneously restarts or displays "Your computer restarted because of a problem." - Apple Support
    Regards,
    - Brenden

  • Trying to restore my iPhone 5 from a backup but its says that it will take over 24 hours to finish. Is there something I can try to do to speed this up? I feel like it shouldn't take this long

    So I have been restoring my iPhone5 from a backup for about 3 hours now however iTunes still says that it is going to take over 24 hours to complete the restore process and the progress bar hasn't moved much at all. I feel like something has gone wrong somehow and it shouldn't take this long to complete. Is there something I can do to speed up this process or do I just have to try to wait it out? I'm scared to just unplug my phone and try again since it might screw something up.

    if u unplug then that could put ur device into recovery mode. i would wait

  • HT4623 I have just updated to ios7 on my iphone and don't like the look and feel of this update. Where are all the colors and texture of all the older isos, all those white background colors,yuk. Is a way to go back to the ios6

    I have just updated to ios7 on my iphone and don't like the look and feel of this update. Where are all the colors and texture of all the older isos, all those white background colors,yuk. Is a way to go back to the ios6

    "Unlike".  iOS 7 doesnt display well on my 4S. iOS 6.1.3 should still be supported for older hardware.  I think I shall me moving to Samsung Galaxy now.  Was really hoping hte new iphone would get a bit larger.

Maybe you are looking for

  • SAP R/3 and miniSAP

    Hi there, I am new to SAP and I recently installed SAP R/3 on my computer which i had bought from Ebay...here is a link with the product that i installed. <a href="http://cgi.ebay.com/ws/eBayISAPI.dll?ViewItem&ssPageName=ADME:B:EOIBSAA:US:11&Item=180

  • Moving from PC to Mac Pro

    Dear All, Having switched my wife's laptop for an Imac last year I am now considering switching my desktop to a mac pro. I love using the imac and have just finished my first dvd using imovie and idvd (family video for grandparents). The process was

  • How to create a web bulk upload in SAP BW

    Hi there, does anyboady has an idea which is the best way to create a bulk upload via web interface where the user can select a csv file and upload data by himself? Thanks in advance. regards, ralph

  • Menu Transition not playing completely

    I have an Encore Project with transition videos created to go from menu to scene selection, and scene selection to menu etc. I also have a first play / intro video. When I build out an image to test it, the intro video plays correctly (to lead into t

  • Finder search

    Okay guys. WHY if I search the keyword app the finder search box it does not show me all the applications but just some of them?