6 Replies Latest reply on Feb 19, 2007 7:30 AM by Newsgroup_User

    ComboBox problem

    David Mok Level 1
      I have made a simple ComboBox, which
      works fine to produce a drop-down
      menu list as the following:

      // MyComboBox.fla
      // with an instance of ComboBox
      // named "swf_load_box"
      // on the stage.

      trace("loading mark:");

      swf_load_box.addItem("test1", "test1.swf");
      swf_load_box.addItem("test2", "test2.swf");
      swf_load_box.addItem("test3", "test3.swf");

      // end of MyComboBox.fla

      Then I try to load the published
      MyComboBox.swf into a simple
      movie

      // shell.fla
      this.createEmptyMovieClip("Shell", this.getNextHighestDepth());
      Shell.loadMovie("MyComboBox.swf");
      // end of shell.fla

      MyComboBox is shown in the movie. But
      when I click on it, there is no
      drop-down menu.

      What did I do wrong?
        • 1. Re: ComboBox problem
          Level 7
          The list part of the ComboBox is created in _root. In your case _root
          (_level0) doesn't have the necessary assets to create the component. The
          trick is to use _lockroot so that the list is created in the loaded clip.


          // shell.fla
          this.createEmptyMovieClip("Shell", this.getNextHighestDepth());


          var lo:Object = new Object();
          lo.onLoadInit = function(target_mc){
          target_mc._lockroot = true;
          }

          var mcl:MovieClipLoader = new MovieClipLoader();
          mcl.addListener(lo);
          mcl.loadClip("MyComboBox.swf", Shell);

          // end of shell.fla


          • 2. Re: ComboBox problem
            MotionMaker Level 1
            See this: Flash 8 Documentation - About loading components

            "Use the _lockroot property when calling loadMovie() ..."
            • 3. Re: ComboBox problem
              David Mok Level 1
              Thanks a lot for your help. It's
              unbelievable that such a simple
              hint solved the problem. I spent a
              whole hour in googling and didn't
              find a clue.

              Now, there is one more related
              problem.
              (I have now put a line
              this._lockroot = true;
              in MyComboBox.fla.)

              In MyComboBox.swf, I could
              click the box and select
              an item. There is a rectangle
              border line for the drop-down box,
              which disappears after an
              item is selected.

              In Shell.swf, the same rectangle
              appears, for the drop-down menu.
              But after an item is selected and
              the menu is gone, the rectangle
              bonder remains. I have to
              click the ComboBox again to make
              it go away.

              Is there a way to force Shell.swf
              to behave in the same way as
              MyComboBox.swf does?
              • 4. Re: ComboBox problem
                Level 7
                I don't see any border issues with the dropdown list.

                However, I just noticed that the focus halo is handled differently depending
                on where you put _lockroot=true;

                If you assign _lockroot in the child movie (this._lockroot=true), the halo
                is drawn around the entire text control of the ComboBox. But if you assign
                _lockroot in the container movie, no focus halo is drawn.





                • 5. Re: ComboBox problem
                  David Mok Level 1
                  Many thanks! It worked as you
                  described.
                  • 6. Re: ComboBox problem
                    Level 7
                    You're welcome!