8 Replies Latest reply on Apr 17, 2009 3:12 PM by kglad

    onEnterFrame won't play

    hoppe11 Level 1

      hi..

       

      I have a script with some onEnterFrame's.. my problem is that I can't evoke more than one of the functions in "onframe()".. after the first function "onframe1()" has ended nothing more happens.. if I switch the two functions ("onframe1()" and "onframe2()")  arround or I escape the first the script still ends after the first function is done

       

      what am I doing wrong?

       

       

      function onframe()
      {
          var i = 0;
          onEnterFrame = function()
          {
              if(i == 10) onframe1();
              if(i == 200) onframe2();
             
              //delete this.onEnterFrame;
             
              i++;
          }
      }

       

      function onframe1()
      {
          var i = 0;
          onEnterFrame = function()
          {
              if(i == 1) act_move(mcTxt_summer, 7, 0.03, 5, -1);
              if(i == 10) act_move(mcTxt_angel, 7, 0.03, 45, -1);
              if(i == 30) act_move(mcTxt_date, 7, 0.03, 20, -1);
              if(i == 40)
              {
                  act_move(mcTxt_year, 7, 0.03, 35, -1);
                  delete this.onEnterFrame;
              }
             
              i++;
          }
      }

       

      function onframe2()
      {
          var i = 0;
          onEnterFrame = function()
          {
              if(i == 1) act_move(mcCarpet07, 6, 0.05, 0, 320)
              if(i == 20) act_move(mcCarpet06, 6, 0.05, 0, 320)
              if(i == 50) act_move(mcCarpet05, 6, 0.05, 0, 320)
              if(i == 60) act_move(mcCarpet04, 6, 0.05, 0, 320)
              if(i == 65) act_move(mcCarpet03, 6, 0.05, 0, 320)
              if(i == 68) act_move(mcCarpet02, 6, 0.05, 0, 320)
              if(i == 70)
              {
                  act_move(mcCarpet01, 6, 0.05, 0, 320)
                  delete this.onEnterFrame;
              }
             
              i++;
          }
      }

        • 1. Re: onEnterFrame won't play
          kglad Adobe Community Professional & MVP

          at any one time, each timeline can have, at most, one onEnterFrame method.

          • 2. Re: onEnterFrame won't play
            hoppe11 Level 1

            if I escape all unnecessary code and I switch the two functions onframe1 and onframe2 arround only the first will be evoked

             

            result:

            "onframe2"

             

            function onframe()
            {
                var i = 0;
                onEnterFrame = function()
                {
                    if(i == 10) onframe2();
                    if(i == 200) onframe1();
                   
                    //delete this.onEnterFrame;
                   
                    i++;
                }
            }

             

            function onframe1()
            {
                var i = 0;
                onEnterFrame = function()
                {
            //        if(i == 1) act_move(mcTxt_summer, 7, 0.03, 5, -1);
            //        if(i == 10) act_move(mcTxt_angel, 7, 0.03, 45, -1);
            //        if(i == 30) act_move(mcTxt_date, 7, 0.03, 20, -1);
                    if(i == 40)
                    {
                        trace('onframe1');
            //            act_move(mcTxt_year, 7, 0.03, 35, -1);
                        delete this.onEnterFrame;
                    }
                   
                    i++;
                }
            }

             

            function onframe2()
            {
                var i = 0;
                onEnterFrame = function()
                {
            //        if(i == 1) act_move(mcCarpet07, 6, 0.05, 0, 320)
            //        if(i == 20) act_move(mcCarpet06, 6, 0.05, 0, 320)
            //        if(i == 50) act_move(mcCarpet05, 6, 0.05, 0, 320)
            //        if(i == 60) act_move(mcCarpet04, 6, 0.05, 0, 320)
            //        if(i == 65) act_move(mcCarpet03, 6, 0.05, 0, 320)
            //        if(i == 68) act_move(mcCarpet02, 6, 0.05, 0, 320)
                    if(i == 70)
                    {
                        trace('onframe2');
            //            act_move(mcCarpet01, 6, 0.05, 0, 320)
                        delete this.onEnterFrame;
                    }
                   
                    i++;
                }
            }

            • 3. Re: onEnterFrame won't play
              hoppe11 Level 1

              how do you mean?

              • 4. Re: onEnterFrame won't play
                kglad Adobe Community Professional & MVP

                i mean if you use:

                 

                onEnterFrame=f1;

                onEnterFrame=f2;

                onEnterFrame=f3;

                 

                only f3 will execute.

                • 5. Re: onEnterFrame won't play
                  hoppe11 Level 1

                  what are the alternatives?

                  • 6. Re: onEnterFrame won't play
                    kglad Adobe Community Professional & MVP

                    apply your onEnterFrame loops to different movieclips or use setInterval() to create multiple loops.

                     

                    this.createEmtpyMovieClip("mc1",1);
                    this.mc1.onEnterFrame=f1;
                    this.createEmtpyMovieClip("mc2",2);
                    this.mc2.onEnterFrame=f2;
                    this.createEmtpyMovieClip("mc3",3);
                    this.mc3.onEnterFrame=f3;
                    
                    • 7. Re: onEnterFrame won't playt
                      hoppe11 Level 1

                      ok.. thanks

                      • 8. Re: onEnterFrame won't playt
                        kglad Adobe Community Professional & MVP

                        you're welcome.