3 Replies Latest reply on Sep 11, 2006 11:08 AM by Newsgroup_User

    Help with Operators

    Anim8steve
      Currently working on a project were I need to assign a series of random options (members) a value, once selected by the user these values need to be added together and a total needs to be given and displayed on screen. So I need help assigning all the members a value and then adding them together also displaying the total.
        • 1. Re: Help with Operators
          Level 7
          The simpest possible thing is to use each member's number. As each
          sprite is selected, just add the member number to the current value of a
          global variable. For instance:

          -------
          global newTotal

          property thisSprite
          property thisMemberNumber

          on beginSprite me
          thisSprite = me.spriteNum
          thisMemberNumber = sprite(thisSprite).memberNum
          end

          on mouseUp me
          newTotal = newTotal + thisMemberNumber
          end
          --------

          Then you can access the value of newTotal anywhere in the movie where
          you need to use it.

          --
          Rob
          _______
          Rob Dillon
          Adobe Community Expert
          http://www.ddg-designs.com
          412-243-9119

          http://www.macromedia.com/software/trial/
          • 2. Re: Help with Operators
            Anim8steve Level 1
            Thanks Rob for the quick response,

            One more Question
            "how do I access the value of the newTotal on the same screen as the selected options?" for instance could the value been shown in a field somewhere on the same screen as the options so that the participant can check their own score?
            • 3. Re: Help with Operators
              Level 7
              Place your text or field member on the stage and add the second line to
              the mouseUp function. Change the name to suit your needs.


              -------
              global newTotal

              property thisSprite
              property thisMemberNumber

              on beginSprite me
              thisSprite = me.spriteNum
              thisMemberNumber = sprite(thisSprite).memberNum
              end

              on mouseUp me
              newTotal = newTotal + thisMemberNumber
              member("show Total").text = string(newTotal)
              end
              --------

              --
              Rob
              _______
              Rob Dillon
              Adobe Community Expert
              http://www.ddg-designs.com
              412-243-9119

              http://www.macromedia.com/software/trial/