7 Replies Latest reply on Jun 23, 2011 9:21 AM by karma007

    Referencing problems: duplicated movie clip with a dynamic text field

    karma007 Level 1

      Dear Sir

       

      I have created a movie clip with the following path to a dynamic text field:

       

      _root.i_lotteryball1.i_ballstrip.i_text.d_text1.text = _global.text1;

       

      I have then duplicated the 'i_lotteryball1' movie clip, and called it 'i_lotteryball2'.

       

      When I try:

       

      _root.i_lotteryball2.i_ballstrip.i_text.d_text1.text = _global.text2;

       

      It changes the text in  'i_lotteryball1' text field aswell as  'i_lotteryball2' text field with the value of '_global.text2'

       

      How can I update each text field with different values.

       

      When I try to change the instance name of the text field inside 'i_lotteryball2'  to 'd_text2', it changes the 'i_lotteryball1' text field instance name aswell to 'd_text2'!!!!!

       

      My objective:

       

       

      _root.i_lotteryball1.i_ballstrip.i_text.d_text1.text = _global.text1;

       

      _root.i_lotteryball2.i_ballstrip.i_text.d_text2.text = _global.text1;

       

      Please help. This is doing my head in........

       

      Thanks in advance....

       

      Charlie

        • 1. Re: Referencing problems: duplicated movie clip with a dynamic text field
          kglad Adobe Community Professional & MVP

          show the code that duplicated your movieclip and assigned text to its descendant textfield.

          • 2. Re: Referencing problems: duplicated movie clip with a dynamic text field
            karma007 Level 1

            Thanks for such a quick reply. Wow!

             

            I didn't use any code to duplicate the movie clip. I copy and pasted the movie clip in layer 1 of frame 1 in the main timeline to layer 2 of frame 1 in the main timeline.

             

            I then selected the newly copied frame in layer 2, and gave it a different instance name of 'i_lotteryball2'.

             

            The path to the text field:

             

            layer 1:

             

            _root.i_lotteryball1.i_ballstrip.i_text.d_text1;

             

            layer 2

             

            _root.i_lotteryball2.i_ballstrip.i_text.d_text1;

             

            So basically, inside the movie clip instance 'i_lotteryball1', is another movie clip intance called 'i_ballstrip' ans so on, until we get to the text field at the end.

             

            When I assign a frame script within the movie clip 'i_ballstrip', I can change the text dynamically of the text field, using:

             

            this.i_text1.d_text1.text = _global.text1;

             

            The global is set as a frame script in the main timeline:

             

            _global.text1 = "10";

             

            If I try and use:

             

            _root.i_lotteryball1.i_ballstrip.i_text.d_text1.text = _global.text1;

             

            ...in the main timeline, the text is not updated but no error.

             

            The problem is, that although the text is updating with the script  inside 'i_ballstrip', it is only updating the text in 'i_lotteryball1', which is logical.

            I want to be able to update text fields inside several instances of the original 'lotteryball' movie clip with different text, passed in as global variables (eventually originating from Flashvars).

             

            I can send you my flash file (Flash 8), if that would help...

             

            Thanks again for all your help...

             

            Charlie

            • 3. Re: Referencing problems: duplicated movie clip with a dynamic text field
              karma007 Level 1

              I forgot to mention that I have scripts attached to both 'i_lotteryball1' and 'i_lotteryball2', which is why I did not use duplicateMovieClip().

               

              The script is identical for each instance. Infact, it comes from an external actionscript file, so the attached script is as simple as this:

               

              #include "draw.as"

               

              I wasn't sure if the script attached to the movieclip would be duplicated & attached, if I used duplicateMovieClip()?

              So, I explicitly copied & pasted the frame, containing the movieclip, instead.

               

              I thought I would mention this, as it maybe helpful.

               

              Thanks

               

              Charlie

              • 4. Re: Referencing problems: duplicated movie clip with a dynamic text field
                kglad Adobe Community Professional & MVP

                don't copy and paste that movieclip.

                 

                delete the one you copied and dragged.  from the library, drag that movieclip to the timeline and assign your new instance name.  retest.

                • 5. Re: Referencing problems: duplicated movie clip with a dynamic text field
                  karma007 Level 1

                  Doh! Doh! Doh! I think my brain fell out of my skull this afternoon. Long day at work and all that....

                   

                  Maybe I just need to duplicate the orginal 'lotteryball' movieclip in the library and drag that to the stage. Give it a new instance name, as before, like 'i_lotteryball2', and voila, all is happy in the Flash garden.

                   

                  Is this the point of 'duplicateMovieClip()'.

                   

                  I guess copying and pasting a frame, is not the same as Duplication?????

                   

                  Duplicating within the library, is!

                   

                  Thanks again...

                   

                  Charlie

                  • 6. Re: Referencing problems: duplicated movie clip with a dynamic text field
                    kglad Adobe Community Professional & MVP

                    the only reason to duplicate the library object (and create an additional library object) is if you're going to make changes on the movieclip's timeline (or one of its children) and you don't want to change all instances of that movieclip.

                     

                    p.s.  you're welcome, and please mark helpful/correct responses, if there are any.

                    • 7. Re: Referencing problems: duplicated movie clip with a dynamic text field
                      karma007 Level 1

                      OK.

                       

                      It was a little more laborious than my original 'eureka' moment.

                       

                      1) Duplicated the original movieclips 'lotteryball1', 'ballstrip1' & 'text1' in the library. Nemed duplicated movieclips, 'lotteryball2', 'ballstrip2' & 'text2' in the library

                      2) Dragged 'lotteryball2' to the stage and named the instance 'i_lotteryball2'

                      3) Swapped all nested movieclips for there new equivalents ('ballstrip1' -> 'ballstrip2', 'text1' -> 'text2'), and named each with a new instance name ('i_ballstrip1' -> 'i_ballstrip2', 'i_text1' -> 'i_text2', 'd_text1' -> 'd_text2')

                      4) Placed frame script in 'i_ballstrip1':

                      this.i_text1.d_text1.text = _global.text1;

                      5) Placed frame script in 'i_ballstrip2':

                      this.i_text2.d_text2.text = _global.text2;

                       

                      Voila.

                       

                      Only problem, I have to repeat the process with another 5 balls. It is my fault for building the project without considering how I was going to reference the text field at the bottom of the movieclip nest.

                       

                      I cannot believe there isn't any easier way, but I guess I was using the same movieclip text field for the two different updates!!!!

                       

                      Thanks for your help anyway...

                       

                      Charlie