3 Replies Latest reply on Jun 27, 2010 10:43 AM by Ned Murphy

    Play a movieclip ONCE if argument is satisfied

    prodigalmaster Level 2

      Inside a function, if:

      playerLevel == 1;

      then:

      MC_lvlup.play();

       

      It plays the movieclip after you get to level 1 but it loops even with a stop(); at the end of the movieclip. I know why, because the argument is still satisfied and so it is trying to MC_lvlup.play(); again.
      I just dont know how to make the movieclip play only once!


      (It should also play the movieclip again after level 2 once) - This is because the movieclip is of text saying "Level Up".

      Thanks for reading, and I hope you have an answer!

        • 1. Re: Play a movieclip ONCE if argument is satisfied
          Ned Murphy Adobe Community Professional & MVP

          If the problem is that player_level is still 1, then right after the test for if player_level == 1 reset its value.

           

          Inside a function, if:

          playerLevel == 1;

          then:

          playerLevel = 0;  // or whatever value when it isn't 1

          MC_lvlup.play();

          1 person found this helpful
          • 2. Re: Play a movieclip ONCE if argument is satisfied
            prodigalmaster Level 2

            Thanks but I want the playerLevel to stay at 1 because it is displayed on the screen. I have really messy code and have confused myself:
            Frame 1(no graphics).

            playerLevelFresh = function () {
                 experienceAll = experience+"/"+nextLvlExp;
                 if (experience<=40) {
                      playerLevel = 0;
                      playerLevel2 = 0;
                 } else if (experience>=40 && experience<100) {
                      playerLevel = 1;
                      nextLvlExp = 100;
                      playerLevel2 = 0;
                 } else if (experience>=100 && experience<200) {
                      playerLevel = 2;
                      nextLvlExp = 200;
                      playerLevel2 = 0;
                 } else if (experience>=200 && experience<350) {
                      playerLevel = 3;
                      nextLvlExp = 350;
                      playerLevel2 = 0;
                 } else if (experience>=350 && experience<475) {
                      playerLevel = 4;
                      nextLvlExp = 475;
                      playerLevel2 = 0;
                 } else if (experience>=475 && experience<700) {
                      playerLevel = 5;
                      nextLvlExp = 700;
                      playerLevel2 = 0;
                 } else if (experience>=700 && experience<1000) {
                      playerLevel = 6;
                      nextLvlExp = 1000;
                      playerLevel2 = 0;
                 } else if (experience>=1000 && experience<1400) {
                      playerLevel = 7;
                      nextLvlExp = 1400;
                      playerLevel2 = 0;
                 } else if (experience>=1400 && experience<1900) {
                      playerLevel = 8;
                      nextLvlExp = 1900;
                      playerLevel2 = 0;
                 } else if (experience>=1900 && experience<2600) {
                      playerLevel = 9;
                      nextLvlExp = 2600;
                      playerLevel2 = 0;
                 } else if (experience>=2600 && experience<3300) {
                      playerLevel = 10;
                      nextLvlExp = 3300;
                      playerLevel2 = 0;
                 }
            }; 
            

            plus a load of other code.

            Then on frame "home" I have a movieclip with instance: MC_lvlup frame 1 of this it has stop();

            when the player gains a level I want this animation to play once. But I have to keep the level the same otherwise it will look weird for the player, seeing his level go to 0 when it plays :/ ???

            • 3. Re: Play a movieclip ONCE if argument is satisfied
              Ned Murphy Adobe Community Professional & MVP

              Then you probably don't want to use the playerLevel to control playing the movieclip, but have some other boolean value that you set true/false to decide whether the movieclip plays or not.  Any command to play the movie should be followed by resetting that boolean value.

              1 person found this helpful