4 Replies Latest reply on Jun 26, 2006 7:54 AM by kglad

    Setting variables and looping a movie

    Palyul Level 1


      I am trying to set enable users to click a button to listen to a chant once or to click a different button to enable them to listen to that chant endlessly. A third button stops the chant.

      Not having trouble with the stop button. :)

      I'm setting a variable when the user clicks the "play" button and then a different variable for the "loop" button. At the end of the movie, I have a frame of action script which checks to see what variable is set. If it is one value, the user will hear the chant again; if it is a different value, the movie goes to frame 1 and stops.

      I had created this originally in Flash 5 and upgraded to MX. In Flash 5 my variables were working. I've fiddle around with the movie since then.

      There's definitely sound sync problems too, that you will see, but I intend to search on that issue in this forum. Of course, any links to similar issues appreciated.
        • 1. Re: Setting variables and looping a movie
          kglad Adobe Community Professional & MVP
          check that your variables have exactly the same names from one location to another. in flash 5, myVar was the same as myvar, but not in flash mx.

          also, make sure all your variables are initialized. in flash 5 and undefined variable was assumed to be zero so incrementing it was ok, but not in flash mx. if you increment an undefined variable, it's still undefined.
          • 2. Setting variables and looping a movie
            Palyul Level 1
            I think I am - here's what I have - yet the movie won't loop if the user clicks on the "loop" button.

            Frame 1:
            on (release) {
            _global.learn = "true";
            gotoAndPlay ("Play");
            }


            Button 1 (Play once):
            on (release) {
            _global.learn = "false";
            gotoAndPlay ("Play");
            }

            Button 2 (Loop):
            on (release) {
            _global.learn = "true";
            gotoAndPlay ("Play");
            }


            Frame 1590 (at end of sound clip):
            if (_global.learn="true") {
            gotoAndPlay("Om_Swasti");
            } else if (_global.learn="false") {
            gotoAndStop("Stopped");
            }
            • 3. Re: Setting variables and looping a movie
              Palyul Level 1
              BTW - I changed to this - and it only would loop continuously instead of returning to Frame 1 ("stopped") and stopping:

              Frame 1 ("Stopped"):
              stop();
              _global.learn = 1;

              Frame 2 ("Play"):
              play():

              Play Once Button:
              on (release) {
              _global.learn = 1;
              gotoAndPlay ("Play");
              }

              Loop Button:
              on (release) {
              _global.learn = 2;
              gotoAndPlay ("Play");
              }


              Frame 1590:
              if (_global.learn = 2) {
              gotoAndPlay("Om_Swasti");
              } else if (_global.learn = 1) {
              gotoAndStop("Stopped");
              }

              ("Om_Swasti" is a frame name).

              Thanks for trying to help! Appreciate it a lot.
              • 4. Re: Setting variables and looping a movie
                kglad Adobe Community Professional & MVP
                you have, at least, 2 errors. most likely your current issue is due to the 2nd error.

                first, only use _global to declare or define your variable. once that's done, don't reuse the _global prefix.

                2nd, to test for equality use the double equal (==). that's was important in flash 5, too so i'm not sure why your flash ever worked.