A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: AS-subtotal and total of results quiz

  1. #1
    Junior Member
    Join Date
    Feb 2005
    Location
    belgium
    Posts
    2

    AS-subtotal and total of results quiz

    Hi,
    I need to develop a survey without using the learningcomponents.
    On every frame there is a question with these options (static text)
    0 points if it’s never happened to you
    1 point if it’s happened once or twice
    2 points if its happened 3-5 times
    3 points if it’s happened more than 5 times

    After this I have one input textfield, the user put the score in this field.
    Than one button.
    And one dynamic textfield.
    When the user clicks on the button, the total score must be appears into the dynamic textfield. I've got a blanc result there and no errors in output.

    Here the script, is this wrong?
    Thanks for helping me.
    mleen.
    ----

    one input Text : instance MyScore, var: score
    one dynamic Text: instance MyTotal, var: total
    one button to get MyTotal: instance name myButton_btn
    ---
    ---
    the script:

    for the button:
    code:
    myButton_btn.onRelease=function(){
    myTotal_txt.text=TotalScore();
    }



    intitialize (in seperate layer):

    code:
    var score=0;
    var totalNumber=0;
    TotalScore=Number(score)+Number(total);


  2. #2
    Inspector General
    Join Date
    May 2001
    Posts
    493

    Re: AS-subtotal and total of results quiz

    Originally posted by mleen


    for the button:
    code:
    myButton_btn.onRelease=function(){
    myTotal_txt.text=TotalScore();
    }



    intitialize (in seperate layer):

    code:
    var score=0;
    var totalNumber=0;
    TotalScore=Number(score)+Number(total);

    [/B]
    the main thing that jumps out at me is that in your button onRelease you reference
    TotalScore()
    the () parenthesis denote a reference to the a function called TotalScore, yet TotalScore is never defined as a function.

    to make it work the way you set out
    change your frame action:
    TotalScore=Number(score)+Number(total);
    to
    code:

    TotalScore=function(){
    return Number(score)+Number(total)
    }




    although i totally endorse functions for code that will be used over and over, in this case you seem to only be adding 2 variables. i would skip the function altogether and simply have your button action do this:
    code:
    myButton_btn.onRelease=function(){
    myTotal_txt.text=Number(score)+Number(total);
    }


  3. #3
    Junior Member
    Join Date
    Feb 2005
    Location
    belgium
    Posts
    2
    tx!! it's working fine now.

  4. #4
    Junior Member
    Join Date
    Feb 2005
    Location
    california
    Posts
    4

    snif!!! i love you!!



    thank you!! it is 410a and im working on a school project, i have been dipping around with this code for over two hours, wondering WHY WHY WHY it was not working NUMBER (variable) - THANK YOU!!!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center