15 Replies Latest reply on Feb 16, 2011 3:40 PM by kglad

    Button is not working on 2nd load

    juresti Level 1

      I have a main swf that loads movies into a clip movieHolder. It loads one movie initially and a button is selected then plays to a frame which loads another movie once a button is pressed in this movie it plays to a frame and at this point / frame I have this code:

       

      stop();
      _parent.movieHolder.loadMovie("Q_1.swf");
      _parent.attachMovie("title_foundational", "ttl_foundational", 1, {_x: 217, _y: 5});
      _parent.attachMovie("buttonblank", "butt_blank", 2, {_x: 22, _y: 5});
          _parent.butt_blank.gotoAndStop (1);
          _parent.butt_blank._alpha = 100;
          _parent.butt_blank.onRelease = function() {
          _parent.gotoAndStop ("secondframe");
          }

       

      The butt_blank is what I am having trouble with. The first time it returns the user to the right place back to the first loaded movie, subsequently when the buttons are clicked the movies again load properly and the code does load the butt_blank, but the code does NOTHING. The user stays on the same frame.

       

       

      This is the code that runds when the user returns to "secondframe"

       

      movieHolder.loadMovie("ShopOutsideAnim01.swf", "ShopOutside");
      ttl_foundational.removeMovieClip();
      butt_blank.removeMovieClip();

       

       

      Any help is greatly appreciated!

        • 1. Re: Button is not working on 2nd load
          kglad Adobe Community Professional & MVP

          butt_blank needs to be removed before another butt_blank is added.

          • 2. Re: Button is not working on 2nd load
            juresti Level 1

            I'll be back Monday to work on this and mark correct!

             

             

            I thought I removed it here once it went to this frame:

             

            This is the code that runds when the user returns to "secondframe"

             

            movieHolder.loadMovie("ShopOutsideAnim01.swf", "ShopOutside");
            ttl_foundational.removeMovieClip();
            butt_blank.removeMovieClip();

             

            maybe it's not the right path.

             

             

            MAybe I need to remove it here:

             

            stop();
            _parent.movieHolder.loadMovie("Q_1.swf");
            _parent.attachMovie("title_foundational", "ttl_foundational", 1, {_x: 217, _y: 5});
            _parent.attachMovie("buttonblank", "butt_blank", 2, {_x: 22, _y: 5});
                _parent.butt_blank.gotoAndStop (1);
                _parent.butt_blank._alpha = 100;
                _parent.butt_blank.onRelease = function() {
                _parent.gotoAndStop ("secondframe");

            butt_blank.removeMovieClip();
                }

             

            Ok Ill see what I can do.

            • 3. Re: Button is not working on 2nd load
              juresti Level 1

              _parent.attachMovie("buttonblank", "butt_blank", 2, {_x: 22, _y: 5});
              _parent.butt_blank._alpha = 100;

               

              _parent.butt_blank.onRelease = function() {
                  _parent.gotoAndStop (2);
                  trace("ahahhhhhahhahahahahahahahah");
                  }

               

               

              Frame 2 of parent:

               

              movieHolder.loadMovie("ShopOutsideAnim01.swf", "ShopOutside");
              butt_blank.removeMovieClip();

               

               

              when it goes back to above code it does not perform gotoAnStop (2) again

              • 4. Re: Button is not working on 2nd load
                kglad Adobe Community Professional & MVP

                do you see that trace()?  if yes, _parent is stopping on its frame2.

                • 5. Re: Button is not working on 2nd load
                  juresti Level 1

                  I do see the trace yes I guess it is not loading the movie then when I click the button the first time it goes back to parent and loads movie, cecond time I see trace my movie does not load into movieHolder or not on top of current movie. Am I missing something???

                   

                  movieHolder.loadMovie("ShopOutsideAnim01.swf", "ShopOutside");
                  ttl_foundational.removeMovieClip();
                  butt_blank.removeMovieClip();

                  • 6. Re: Button is not working on 2nd load
                    kglad Adobe Community Professional & MVP

                    yes, you're missing something.  you are probably confused about what you expect _parent to be.  use:

                     

                    trace(_parent)

                     

                    just before that _parent.goto

                     

                    and if you have more than one _parent.goto which is, i suspect, causing your confusion, trace them all.

                    • 7. Re: Button is not working on 2nd load
                      juresti Level 1

                      both times it traces to _level0 the first time the button works, second time no. Maybe I have it set up wrong??


                      I have a main movie with an mc instance name "movieHolder" on frame 1 main movie loads ShopOutsideAnim01.swf then user presses butoon moves to a frame in ShopOutsideAnim01.swf in that frame code loads ToolShopAnim01.swf into _parent.movieHolder. In ToolShopAnim0.swf a button is attached to go back to parent which is the main movie this time it goes to the 2nd frame because there is code in the first frame for scorm so it cant be reinitialized so in frame 2 I want it to load ShopOutsideAnim01.swf but it traces as if it went to frame 2 but ToolShopAnim01.swf remains as if ShopOutsideAnim01.swf does not load.

                       

                      startPreload is in frame 1 of the Main Movie this loads ShopOutsideAnim01.swf into movieHolder on frame 1

                       

                      stop();
                      // this function runs the preloader
                      // it is to be used with the onEnterFrame
                      // of the preloader animation
                      function preloadContainer(){
                          
                           // get bytes loaded and total from container_mc
                           var bytes_loaded = movieHolder.getBytesLoaded();
                           var bytes_total = movieHolder.getBytesTotal();
                          
                          
                           // stop and hide the movie so it wont play or
                           // be seen while progressively downloading
                           // (keep trying if it exists or not just to be sure)
                           movieHolder.stop();
                           movieHolder._visible = false;
                          
                           // if bytes_total is a valid number and greater than 0
                           if (bytes_total > 0){
                              
                               // get percent loaded
                               var percent_loaded = bytes_loaded/bytes_total;
                              
                               // update the value in the preloader
                               preloader_mc.value = percent_loaded;
                                  
                               // check if preloading is complete
                               if (percent_loaded == 1){
                                  
                                   // play and show the container clip
                                   movieHolder.gotoAndStop(1);
                                   movieHolder._visible = true;
                                  
                                   // remove the preloader movie clip
                                   preloader_mc.removeMovieClip();
                                  
                                   // delete the onEnterFrame event handler running this function
                                   delete onEnterFrame;
                               }
                           }
                      }

                       

                      Frame 2 of Main Movie:

                      this is in order not to reinitialize scorm code on first frame so I go back to 2nd frame of Main Movie


                      movieHolder.loadMovie("ShopOutsideAnim01.swf", "ShopOutside");
                      ttl_foundational.removeMovieClip();
                      butt_blank.removeMovieClip();

                       

                      Code in ShopOutsideAnim0.swf

                      this is in frame 90 once animation is played that loads the ToolShopAnim01.swf

                       

                      stop();

                       

                      _parent.startPreload("ToolShopAnim01.swf");

                       

                       

                      Code in ToolShopAnim0.swf

                      this is where I am basically trying to make a HOME button the trace runs but the ShopOutsideAnim0.swf does not load (code in frame 2 of Main Movie)

                       

                      _parent.attachMovie("buttonblank", "butt_blank", 2, {_x: 22, _y: 5});
                          _parent.butt_blank.onRelease = function() {
                          trace(_parent);
                          _parent.gotoAndStop (2);
                          trace("ahahhhhhahhahahahahahahahah");
                          }

                       


                      • 8. Re: Button is not working on 2nd load
                        kglad Adobe Community Professional & MVP

                        use the trace() function to debug your app.

                        1 person found this helpful
                        • 9. Re: Button is not working on 2nd load
                          juresti Level 1

                          If I put a trace in frame 2 it traces the first time but not the second time.

                          • 10. Re: Button is not working on 2nd load
                            kglad Adobe Community Professional & MVP

                            use the trace() function to find out why.  is a new movieclip button being created?

                            1 person found this helpful
                            • 11. Re: Button is not working on 2nd load
                              juresti Level 1

                              I just had it load the movie in movieHolder once button was pressed and not go to frame 2 of the parent. Maybe you cant go back to the same frame.

                               

                              _parent.attachMovie("buttonblank", "butt_blank", 2, {_x: 22, _y: 5});
                                  _parent.butt_blank.onRelease = function() {
                                  _parent.movieHolder.loadMovie("ShopOutsideAnim01.swf", "ShopOutside");
                                  }

                              • 12. Re: Button is not working on 2nd load
                                juresti Level 1

                                I realized that once I was on frame 2 on the main movie and loaded a new movie which was then trying to go back to the main movie frame 2 and run the code. The main movie never left frame 2 so there was nothing to go back to it was already at that point so the code I assume could not run. I moved the playhead once the movie was loaded in frame 2 to frame 3. So now it WILL go to frame 2 and run the code

                                 

                                movieHolder.loadMovie("ShopOutsideAnim01.swf", "ShopOutside");
                                trace("WTF");
                                gotoAndStop(3);

                                • 13. Re: Button is not working on 2nd load
                                  kglad Adobe Community Professional & MVP

                                  the trace() function is, by far, the most help tool for debugging apps inside flash.  use it often.

                                   

                                  p.s.  please mark helpful/correct answers, if there are any.

                                  1 person found this helpful
                                  • 14. Re: Button is not working on 2nd load
                                    juresti Level 1

                                    I understand kglad. It's just I think this was a frame issue not a path issue. I only figured it out by making a really simple version of my problem.

                                     

                                    But yea I see what u mean.

                                     

                                    Thankss!

                                    • 15. Re: Button is not working on 2nd load
                                      kglad Adobe Community Professional & MVP

                                      you're welcome.  keep using trace().