9 Replies Latest reply on Mar 13, 2010 4:53 PM by kglad

    Loading Multiple movie clips inside another movie clip

    xcmuddman Level 1

      Hi All

       

      I was wondering about the flexability of loading movies into a movie clip.

      Currently, I am well able to load one movie into a movie "loader" clip, but thought maybe there is a way to load additional movie clips into that same "loader" clip, as i am starting to accumulate several different graphics that i need to have be inside movie clips so that i can make them change colors on the same frame when needed.

       

      i shot from the hip and tried this code, but didnt have any luck:

       

      mc_LCD_loader.attachMovie("hilight", "g", 1), ("header", "X", 1);
      mc_LCD_loader.g._x = 0;
      mc_LCD_loader.g._y = 1000;

      mc_LCD_loader.X._x = 0;
      mc_LCD_loader.X._y = 1000;

       

      - - - where "hilight" is the identifier name of a given movie clip and "header" is the identifier of a given movie clip in the same library...

       

      "hilight" loads fine

       

      i dont fully understand what "g" means to the identifier...

       

      i am just unsure of how or if it is even possible to load another MC into the same MC Loader...

       

      is it possible? if so could anyone give me a hint?

       

      thank you!

       

      - patrick

        • 1. Re: Loading Multiple movie clips inside another movie clip
          kglad Adobe Community Professional & MVP

          that's not "loading" a movieclip.  that's "attaching" a movieclip.

           

          and yes, you can attach many movieclips to a target parent.  but you must understand that 3rd parameter.  it's an non-negative integer that assigns the depth of the child movieclip.  because no two children can be at the same depth, that 3rd parameter must change values if you want to add new children.

           

          in addition, the 2nd parameter is the new child's _name.  you'll want to use different names if you need to reference one of the children later in your project:

           

           

           

          mc_LCD_loader.attachMovie("hilight", "g"+1, 1;

          mc_LCD_loader.attachMovie("hilight", "g"+2, 2);

          mc_LCD_loader.attachMovie("hilight", "g"+3, 3);

          1 person found this helpful
          • 2. Re: Loading Multiple movie clips inside another movie clip
            xcmuddman Level 1

            Thanks KGLAD...

             

            so i have 3 movies with the identifiers:

             

            hilight

            header

            volume

             

            i would load them all at the beginning of my timeline as so:

             

            mc_LCD_loader.attachMovie("hilight", "g"+1, 1;

            mc_LCD_loader.attachMovie("header", "g"+2, 2);

            mc_LCD_loader.attachMovie("volume", "g"+3, 3);

             

            ???

             

            im just not sure how to have control over their positioning...

             

            mc_LCD_loader.g._x = 0

            mc_LCD_loader.g._y = 0

            • 3. Re: Loading Multiple movie clips inside another movie clip
              kglad Adobe Community Professional & MVP

              to reference your newly created child movieclips, you can use:

               

               

              mc_LCD_loader.attachMovie("hilight", "g"+1, 1);

              mc_LCD_loader.attachMovie("header", "g"+2, 2);

              mc_LCD_loader.attachMovie("volume", "g"+3, 3);

               

              mc_LCD["g"+1]._x = 100;
              mc_LCD["g"+2]._x = 200;
              mc_LCD["g"+3]._x = 300;


              that reference will always work.  but, it's "wordy" so shortcuts are often used:

              var mc:MovieClip = mc_LCD_loader.attachMovie("hilight", "g"+1, 1);
              mc._x=100;
              mc = mc_LCD_loader.attachMovie("header", "g"+2, 2);

              mc._x = 200;
              mc = mc_LCD_loader.attachMovie("volume", "g"+3, 3);
              mc._x = 300;
              • 4. Re: Loading Multiple movie clips inside another movie clip
                xcmuddman Level 1

                thanks KGLAD. got it working properly... this saves me a bunch of library space now.

                 

                i wanted to try to load movie clips containing dynamic text boxes in them into an mc_loader too, but since i am assiging variables to the dynamic text box instance in order to display text this way i have no idea of how to associate the attach movie clip to the dynamic text box or visa versa.

                 

                any thoughts?

                • 5. Re: Loading Multiple movie clips inside another movie clip
                  kglad Adobe Community Professional & MVP

                  do you mean attach movieclip?

                   

                  it's misleading when you use terminology incorrectly.  you'll waste people's time and your own time when you do that.

                   

                  the help you'll get and need for loading movieclips is not the same as the help you get or need when attaching movieclips.

                  • 6. Re: Loading Multiple movie clips inside another movie clip
                    xcmuddman Level 1

                    yes. im sorry. i meant attaching movieclips.

                     

                    sorry about that.

                    • 7. Re: Loading Multiple movie clips inside another movie clip
                      kglad Adobe Community Professional & MVP

                      if your movieclips with linkage id hilight, header and volume each had a textfield with instance name tf, you could use:

                       

                       

                       

                      mc_LCD_loader.attachMovie("hilight", "g"+1, 1);

                      mc_LCD_loader.attachMovie("header", "g"+2, 2);

                      mc_LCD_loader.attachMovie("volume", "g"+3, 3);

                       

                      mc_LCD["g"+1]._x = 100;
                      mc_LCD["g"+2]._x = 200;
                      mc_LCD["g"+3]._x = 300;
                      mc_LCD["g"+1].tf.text = "this is text"
                      mc_LCD["g"+2].tf.text = "other text"
                      mc_LCD["g"+3].tf.text = "volume text";

                       

                      that reference will always work.  but, it's "wordy" so shortcuts are often used:

                       

                      var mc:MovieClip = mc_LCD_loader.attachMovie("hilight", "g"+1, 1);
                      mc._x=100;
                      mc.tf.text = "this is text"

                      mc = mc_LCD_loader.attachMovie("header", "g"+2, 2);

                      mc._x = 200;
                      mc.tf.text = "other text"
                      mc = mc_LCD_loader.attachMovie("volume", "g"+3, 3);
                      mc._x = 300;
                      mc.tf.text = "volume text"
                      1 person found this helpful
                      • 8. Re: Loading Multiple movie clips inside another movie clip
                        xcmuddman Level 1

                        Thanks KGLAD!!!

                         

                        that is great help!

                         

                        i have a question though on this... is there still a way to execute the following code with an attached movie clip inside of another one...

                        i had a counter working nicely with a movie clip that was not attached to another one.

                        Now i would like to try to get the following code with an attached movie clip with identifier name "counter2" containing a dynamic text box "counter2_text" to increment as it was when it was not attached to a movie... do you think you can take a look?

                         

                         

                        btn1 and btn2 are also movie clips

                         

                         

                         

                         

                         

                        mc_LCD_text_selected_loader.attachMovie("counter2", "g"+2, 2);

                         

                        mc_LCD_text_selected_loader["g"+2]._x = -40;
                        mc_LCD_text_selected_loader["g"+2]._y = 72;

                         

                         

                        var Counter:Number;
                        var p_m:Boolean;
                        var Cal_Speedo1:Number;

                         


                        Counter=0;
                        Cal_Speedo1=0;

                         

                        mc_LCD_text_selected_loader["g"+2].counter2_text.text = Cal_Speedo1;

                         

                        btn1.change = 1;
                        btn1.onPress = function() {
                            p_m=true;
                            this.onEnterFrame = editTF;

                         

                        };
                        btn1.onRelease = function() {
                            delete this.onEnterFrame;
                            Counter=0;
                        };
                        btn2.change = -1;
                        btn2.onPress = function() {
                            p_m=false;
                            this.onEnterFrame = editTF;
                        };
                        btn2.onRelease = function() {
                            delete this.onEnterFrame;
                            Counter=0;
                        };

                         

                        function editTF(){
                            Counter+=1;
                                if (Counter<10){
                                    btn1.change=1;
                                }
                                else if (Counter >10 and Counter<30){
                                    btn1.change=1;
                                }
                                else if (Counter>30){
                                    btn1.change=10;
                                }
                                if (Counter<10){
                                    btn2.change=-1;
                                }
                                else if (Counter >10 and Counter<30){
                                    btn2.change=-1;
                                }
                                else if (Counter>30){
                                    btn2.change=-1;
                                }
                           
                           
                            mc_LCD_text_selected_loader["g"+2].counter2_text.text = this.change+Number(mc_LCD_text_selected_loader["g"+2].counter2_text.text);
                            if (mc_LCD_text_selected_loader["g"+2].counter2_text.text<-15){
                                mc_LCD_text_selected_loader["g"+2].counter2_text.text=-15;
                            }
                            else if(mc_LCD_text_selected_loader["g"+2].counter2_text.text>15){
                                mc_LCD_text_selected_loader["g"+2].counter2_text.text=15;
                            }
                        }

                         

                         

                         

                        if i could get this to work that would be the best thing ever

                         

                         

                        thanks.

                         

                        pat

                        • 9. Re: Loading Multiple movie clips inside another movie clip
                          kglad Adobe Community Professional & MVP

                          i see this is a duplicate question.