8 Replies Latest reply on Aug 8, 2011 1:40 PM by kglad

    Movieclip inside movieclip

    106dutch

      I was wondering if this was possible:

       

      I have a scrollpane and code on frame 1 of my main timeline:


      [CODE]
      _root.counter = 0;

       

      var i:Number=0;
      var mcMain:MovieClip;

       

      function init() {
      //empty movie clip in library with linkage name "scrollMovieClip"
      scrollPane.contentPath = "scrollMovieClip";
      mcMain = scrollPane.content;
      //trace(mcMain);
      }
      init();

       

      scrollPane._visible = false;
      textBox._visible = false;
      btnClose._visible = false;
      backBox._visible = false;

       

      shopPork.onRelease = function() { 
      mcMain.attachMovie("pork", "test"+i, mcMain.getNextHighestDepth(),{_y:62*i+5, _x:5});
      i++;
      scrollPane.invalidate();
      _root.counter += 1;
      }
      }
      [/CODE]

       

      but the movieclip I've referenced above shopPork is located inside a movie clip called porkDetail and porkDetail is located inside a movie clip called Print1.  This is the code that is on Frame 1 of the Print 1 movie clip:


      [CODE]
      var buttonListener:Object = new Object();
      buttonListener.change = function(evt:Object) {
      // when the current row changes in the DataGrid, launch a new popup window displaying the product's details.
      myWindow = mx.managers.PopUpManager.createPopUp(_root, mx.containers.Window, true, {title:evt.target.selectedItem.name, contentPath:"ProductForm", closeButton:true});
      // set the dimensions of the popup window.
      myWindow.setSize(340, 210);
      // define a listener which closes the popup window when the close button in the upper right-hand corner is clicked.
      var closeListener:Object = new Object();
      closeListener.click = function(evt) {
        evt.target.deletePopUp();
      };
      myWindow.addEventListener("click", closeListener);
      }
      [/CODE]

       

      Obviously when I run this the shopPork.onRelease function does not work.   Is there some way I can get this function to work when the code is on the main timeline and the movieclip is located several layers up?  I was thinking something like the reverse of _parent._parent, but I can't seem to find any info on this.  Is this even possible to do?   Thank you.

        • 1. Re: Movieclip inside movieclip
          kglad Adobe Community Professional & MVP

          but the movieclip I've referenced above shopPork is located inside a movie clip called porkDetail and porkDetail is located inside a movie clip called Print1.

           

          then use:

           

          Print1.porkDetail.shopPork.onRelease=function(){

          .

          .

          }


          • 2. Re: Movieclip inside movieclip
            106dutch Level 1

            I tried as you suggested, but the shopPork mc still did not work. Here is the order of what is happening:

             

            First I have the main timeline. On the main timeline I have mc "print1", within "print1" I have an invisible button (invButPork). The code on "invButPork" is:

            on (press) {
            import mx.managers.PopUpManager;
            import mx.containers.Window;
            var win = PopUpManager.createPopUp(_parent, Window, true, {closeButton:true, contentPath:"PorkDetail"});
            _parent._alpha=25;
            win.setSize(405,265);
            win.move(55,115);
            function click(evt){
            evt.target.deletePopUp();
            _parent._alpha=100;
            }
            win.addEventListener("click", this);
            }

             

            when the user presses the "invbutpork" button a window component comes up and loads the mc "PorkDetail" into it. Within the "PorkDetail" mc there is another mc called "shopPork". When they click on "shopPork" it should load the mc "pork" into the scrollpane located on frame1 of my main timeline.

             

            Does the "invbutpork" button and the window component have to get factored in as well? I tried all different variables, but nothing seemed to work. I even tried putting "shopPork" directly inside "print1" and using the code:

            print1.shopPork.onRelease = function() {
            //attaching blueMovie to the content location stored in mcMain
            mcMain.attachMovie("pork", "test"+i, mcMain.getNextHighestDepth(),{_y:62*i+5, _x:5});
            i++;
            scrollPane.invalidate();
            _root.counter += 1;
            }

             

            This did not work either. The only time I could get it to work is if I put "shopPork"directly on the main timeline and used the code:

            shopPork.onRelease = function() {
            //attaching blueMovie to the content location stored in mcMain
            mcMain.attachMovie("pork", "test"+i, mcMain.getNextHighestDepth(),{_y:62*i+5, _x:5});
            i++;
            scrollPane.invalidate();
            _root.counter += 1;
            }

            then it works just fine, but is not what I need.

             

            Any other suggestions or ideas as to why it is not working? Thanks!

            • 3. Re: Movieclip inside movieclip
              kglad Adobe Community Professional & MVP

              what do the following trace() functions reveal:

               

              trace(Print1);

              trace(Print1.porkDetail);

              trace(Print1.porkDetail.shopPork);

              1 person found this helpful
              • 4. Re: Movieclip inside movieclip
                106dutch Level 1

                trace(mcMain);        

                _level0.scrollPane.spContentHolder

                trace(Print1);

                undefined        

                    

                trace(Print1.porkDetail);

                undefined

                 

                trace(Print1.porkDetail.shopPork);

                undefined

                • 5. Re: Movieclip inside movieclip
                  106dutch Level 1

                  when I do the following:

                   

                  trace(invbutpork);     -  from the timeline of the mc Print1 , this is what I get:

                   

                  _level0.print1.invbutpork
                  _level0.Pages.FTP.Print.invbutpork

                   

                  If I do it from the main timeline

                   

                  trace(print1.invbutpork);  it comes back undefined

                  • 6. Re: Movieclip inside movieclip
                    kglad Adobe Community Professional & MVP

                    1.  print1 is not the same as Print1.  use the correct case.  your print1 movieclip is print1.  it's not Print1.

                     

                    2.  if trace(print1.invbutpork) is undefined on the main timeline, it's executing before print1.invbutpork exists.

                    1 person found this helpful
                    • 7. Re: Movieclip inside movieclip
                      106dutch Level 1

                      ok so I went to frame three in my timeline (where print1 is located) and did a trace from that frame and this is what it returned:

                      _level0.print1.invbutpork

                      However I still cannot locate my PorkDetail mc or my shopPork mc.

                       

                      Could it be because I do not physically have PorkDetail on the print1 mc?  It is  a mc located in the library only.  What happens is that when a user click on invbutpork (which is a button physically on print1) a popup window comes up and loads the PorkDetail mc into the window. shopPork mc is physically in this PorkDetail mc - not just in the library.  Here is the code located on invbutpork:

                       

                      on (press) {
                      import mx.managers.PopUpManager;
                      import mx.containers.Window;
                      var win = PopUpManager.createPopUp(_parent, Window, true, {closeButton:true, contentPath:"PorkDetail"});
                         _parent._alpha=25;
                      win.setSize(405,265);
                      win.move(55,115);
                      function click(evt){
                      evt.target.deletePopUp();
                      _parent._alpha=100;
                      }
                      win.addEventListener("click", this);
                      }

                       

                      Is it still possible to reference the shopPork mc from the main timeline?

                      • 8. Re: Movieclip inside movieclip
                        kglad Adobe Community Professional & MVP

                        1.  remove all code from objects.  that on(press) code should be converted to yourbutton.onPress=function(){...}  code.

                         

                        2.  you can reference invbutpork using:

                         

                        win.content.invbutpork

                         

                        AFTER your window is created and after your remove that "var" making win local to the onPress function.

                        1 person found this helpful