3 Replies Latest reply on Apr 30, 2008 12:49 PM by chewbears

    Multiple variables

    chewbears Level 1
      I would like to have one variable statement that contains more then one variable with an if statement that adds them up. So how would I make a working expression like the one in the posted code (heavy + medium + light). The one I posted does not work and I was wondering if it is even possible.

        • 1. Re: Multiple variables
          dsdsdsdsd Level 1
          var light:Number = 1, medium:Number = 3, heavy:Number = 5;
          onEnterFrame = function():Void
          trace(heavy + medium + light); // outputs 9, on every frame

          your error may be related to your referenced mc's
          • 2. Re: Multiple variables
            robdillon Most Valuable Participant
            There is nothing wrong with the code itself. Using an onEnterFrame event for this sort of action is a really, really, bad idea. OnEnterFrame is a repeating event, and so this action will execute over and over again.

            If the movieClips that are referenced here are not doing what you want then they may be out of the scope of this function.

            Are you seeing any errors? Have you tried a trace() to test anything?
            • 3. Multiple variables
              chewbears Level 1
              I changed things a bit but now my movie doesn't play. I am sure I will get it to work. Instead of the above I just used

              if(_root.counter > 6){

              and instead of putting counter++ to add 1, i wrote

              _root.counter = _root.counter +5;


              _root.counter = _root.counter +3;

              etc on each of the objects. Then I just linked a dynamic text box for display.

              The only thing is with this when the counter is > then 6 it only and I tell it to gotoAndPlay(2) on my movie it goes to 2 and stops, it does not play the entire movie.