7 Replies Latest reply on Oct 3, 2010 9:14 AM by Ned Murphy

    Replacing default external w/ button click

    a_bosiger

      My container (emptyMC) will load 4 external movies and loop as
      default when someone comes to the site.

       

      Right now the code for the empty mc (emptyMC) is:

       

      var loader:MovieClipLoader = new MovieClipLoader();
      this.createEmptyMovieClip("emptyMC",1);
      loader.loadClip("image1.jpg",emptyMC);

       

      It loads the sample default image great.

       

       

      What needs to happen is when someone clicks Button1, Button2, Button3, or Button4,
      (which are movie clip buttons) the corresponding movie needs to load on the click of the button
      in the empty movie clip (emptyMC) and replace the default movie loop.

       


      Movie Loop default plays in "emptyMC" at entrance of site

       

      Button1 is clicked, Movie Loop default is replaced in "emptyMC" with Movie1

       

      Button2 is clicked, Movie Loop default is replaced in "emptyMC" with Movie2

       

      Button3 is clicked, Movie Loop default is replaced in "emptyMC" with Movie3

       

      Button4 is clicked, Movie Loop default is replaced in "emptyMC" with Movie4

       

       

       

      These are all external files.

       

      Thank you so much.

        • 1. Re: Replacing default external w/ button click
          Ned Murphy Adobe Community Professional & MVP

          Just assign instance names to the buttons and assign code to each one as shown below...

           

          btn1.onRelease = function(){
              loader.loadClip("image2.jpg",emptyMC);
          }

           

          Whatever is in emptyMC will be replaced by whatever you load into it.

          • 2. Re: Replacing default external w/ button click
            a_bosiger Level 1

            Thank you, Ned, for helping me out.

             

            The button has this code attached within the button movie clip:

            Button3 is the movie clip instance. The code takes a blank square box,

            puts an "x" in the center when clicked and then removes the "x"

            when another box is clicked.

             

             

            on (release) {
                if (_root.Button3._currentframe == 6) {
                    _root.Button3.gotoAndPlay(7);
                }
                // other actionscript functions for when button is pressed,
                // such as:loadMovie("your.swf","your_mc")
            -->??    gotoAndPlay(2);
            }

             

             

            Can you tell me where I would place your code (or part of your code)

            within the structure I have going?

             

            I can't get it to work. It must be so obvious...

             

            Thanks again

            • 3. Re: Replacing default external w/ button click
              Ned Murphy Adobe Community Professional & MVP

              What I would do is have all the code in the main timeline to make it easier to find/manage.

               

              If the movieclip is called Button3, then just place the code on the main timeline.

               

              Button3.onRelease = function() {
                  if(Button3._currentframe == 6) {
                      Button3.gotoAndPlay(7);
                  }
                   loader.loadClip("image2.jpg",emptyMC);
              }

              • 4. Re: Replacing default external w/ button click
                a_bosiger Level 1

                The image will load but I lose the down state with the filled box indicating the current selection.

                 

                Here's how the button mc is:

                 

                On the main stage there's 4 button mc's (Button1, Button2, Button3 Button4)

                They are all on the same frame.

                -double click to edit the movie clip-

                 

                Layer 1

                Frame 1: box outline

                Frame 6: box outline w/ "x"

                Frame 11: box outline

                Classic Tween between each set of frames

                 

                Layer 2

                A button with this code:

                on (release) {
                    if (_root.Button1._currentframe == 6) {
                        _root.Button1.gotoAndPlay(7);
                    }
                    gotoAndPlay(2);
                }


                on (release) {
                    if (_root.Button2._currentframe == 6) {
                        _root.Button2.gotoAndPlay(7);
                    }
                    gotoAndPlay(2);
                }

                 

                on (release) {
                    if (_root.Button3._currentframe == 6) {
                        _root.Button3.gotoAndPlay(7);
                    }
                    gotoAndPlay(2);
                }

                 

                on (release) {
                    if (_root.Button4._currentframe == 6) {
                        _root.Button4.gotoAndPlay(7);
                    }
                    gotoAndPlay(2);
                }

                 

                and then

                stop(); (for Layer 1's Frame 1)

                stop(); (for Layer 1s Frame 6)

                gotoAndPlay(1); (for Layer 1s Frame 11)

                Classic Tween between each set of frames

                 

                 

                This is working great. I go to the main stage and add this code to the actions

                layer in frame 3:

                 

                Button2.onRelease = function()

                    }
                     loader.loadClip("image2.jpg",emptyMC);
                }

                 

                and I lose the down (filled box) state.

                I'm really lost...

                Thanks for helping me out.

                • 5. Re: Replacing default external w/ button click
                  Ned Murphy Adobe Community Professional & MVP

                  Actually, you have me lost at the moment.  What you just described has four button mc's, and if you edit one of them(?) inside there are four buttons?  You should get all your code on the main timeline.  Then it willl be easier for you to determine how to target the different pieces.

                   

                  But foregoing doing that, if you know where in your current code you would want to load another image, then try adding this line in to what you have instead of what I offered earlier (using whatever file you intend in place of image2.jpg).

                   

                  _root.loader.loadClip("image2.jpg", root.emptyMC);

                  • 6. Re: Replacing default external w/ button click
                    a_bosiger Level 1

                    Thanks so much, Ned, for hanging with me on this one.

                     

                    I got it to work!

                     

                    I brought all the button mc function code to main timeline. Tweaked each button abit.

                    Added the loader function for each button mc to the Actions layer (top)—works beautifully!

                     

                    Thanks again!