8 Replies Latest reply on Jun 20, 2007 5:01 AM by Newsgroup_User

    Component Conflicts

    zibber
      Hi Can anyone help me please as this has been drving me mad for nearly a full day.

      basically i want to attach a movie clip to the stage and then whena button is clicked it is removed my code for this is below:

      createPanel();

      function createPanel(){

      var test3 = attachMovie("pvtChat", "tester", this.getNextHighestDepth())
      test3.closer.onRelease = function() {
      removeMovieClip(test3);
      }
      }

      now the problem i have just discovered after a lot of messing is that two componets i am using, combobox and checkbox seem to stop the removeclip from happening. If i remove these form the libray the above works fine. Can anyone help me here or am i destined jsut to accept this as a flash glitch that cant be resolved?

      thanks in advance

      ade
        • 1. Re: Component Conflicts
          MurMeeKeer Level 1
          Hi,

          this is unbelievable!!!

          Not only check box and combo box components. If you have any component in your library, this is not working.

          Can anyone flood some light.....please?
          • 2. Re: Component Conflicts
            zibber Level 1
            the other interesting issue here is that this works fine if u call the function from a button click. But fails to work if u call the function just on the frame. Unfortunaly i cant use button clicks for what i want to do:( any pointers outhere?
            • 3. Re: Component Conflicts
              Level 7
              The problem lies in the way depths are managed in the component framework.
              With components included in your swf, MovieClip.getNextHighestDepth() will
              return a value outside the range that removeMovieClip can handle.

              One way to handle it is to use the DepthManager class that comes with the
              component framework. Something like this:

              import mx.managers.DepthManager;

              var test3 = attachMovie("pvtChat", "tester", this.getNextHighestDepth())
              test3.setDepthTo(DepthManager.kTop);

              test3.closer.onRelease = function() {
              removeMovieClip(test3);
              }


              • 4. Re: Component Conflicts
                Greg Dove Level 4
                Plenty of the livedocs comments say that if you're using v2 components you should use depthmanager and not getNextHighestDepth() to manage the depths yourself. After a couple of years of not using it I think this is the first example I've seen of why its necessary.

                Interestingly enough if I publish it for flash player 9/as2 the problem is not there.

                Anyhow this fixed it for me:

                import mx.managers.DepthManager;
                createPanel();

                function createPanel(){
                var test3 = this.createChildAtDepth("pvtChat",DepthManager.kTopmost, {_name:"tester"})
                test3.closer.onRelease = function() {
                removeMovieClip(test3);
                }
                }
                • 5. Re: Component Conflicts
                  zibber Level 1
                  GWD u r my saviour thank you works perfectly
                  • 6. Re: Component Conflicts
                    Greg Dove Level 4
                    You're welcome. It looks like this is all that's needed (although the createChildAtDepth method works too).

                    var test3 = attachMovie("pvtChat", "tester", DepthManager.kTopmost)


                    I also found an official explanation just now here:
                    http://kb.adobe.com/selfservice/viewContent.do?externalId=tn_19435&sliceId=2
                    • 7. Re: Component Conflicts
                      Greg Dove Level 4
                      oops. Sorry Raymond - I just saw your post arrive - you answered earlier than me but there was a lag before it got here. I've always managed to avoid needing to use DepthManager without really trying to do so... (perhaps I've been lucky - or foolish or both)... until I saw this example. I didn't know whether to use kTopmost or kTop here to give the equivalent result of getNextHighestDepth()
                      • 8. Re: Component Conflicts
                        Level 7
                        Yeah. I'm not that familiar with DepthManager either. I always use utility
                        functions instead of removeMovieClip and removeTextField -- they check
                        depths and swap if necessary before removing.