20 Replies Latest reply on Sep 8, 2010 9:56 AM by kglad

    Drop-down menu text

    MatAut Level 1

      I can't figure out why the text is not appearing in my drop-down menu. When I click on the menu just the backgrounds appear for each selection, but no text on them. Any ideas? Thanks.

       

      var menuButtons:Array = ["Skin Tone"];

      var subMenu1:Array = ["White", "Brown", "Tan", "Olive"];

      var chosenMenu:Array = new Array();

      var subMenuOpened:Boolean = false;

      var whichSubMenu:Number = new Number();

      var currentPosition:Number = new Number();

       

      for (i=0; i<menuButtons.length; i++) {

                  this.attachMovie("skinMenu", "menuButton"+i, this.getNextHighestDepth());

                  this["menuButton"+i]._x = 131+(115*i);

                  this["menuButton"+i]._y = 94.3;

                  this["menuButton"+i].skinMenuTxt.text = menuButtons[i];

                  this["menuButton"+i].onPress = function():Void {

                              whichSubMenu = Number(this._name.substr(-1, 1));

                              currentPosition = this._x;

                              if (!subMenuOpened) {

                                          subMenuOpened = true;

                                          openSubMenu(whichSubMenu, currentPosition);

                              } else {

                                          closeSubMenu();

                                          openSubMenu(whichSubMenu, currentPosition);

                              }

                  };

      }

       

      function openSubMenu(whichSubMenu, currentPosition):Void {

                  chosenMenu = eval("subMenu"+(whichSubMenu+1));

                  for (j=0; j<chosenMenu.length; j++) {

                              this.createEmptyMovieClip("subMenuHolder_mc", this.getNextHighestDepth());

                              subMenuHolder_mc.attachMovie("skinMenu", "subMenuButton"+j, this.getNextHighestDepth());

                              subMenuHolder_mc["subMenuButton"+j]._x = currentPosition;

                              subMenuHolder_mc["subMenuButton"+j]._y = 94.3+(j*23);

                              subMenuHolder_mc["subMenuButton"+j].skinMenuTxt.text = chosenMenu[j];

                              subMenuHolder_mc["subMenuButton"+j].onRelease = subMenuHolder_mc["subMenuButton"+j].onReleaseOutside=function ():Void {

                                          closeSubMenu();

                              };

                  }

      }

       

      function closeSubMenu():Void {

                  removeMovieClip(subMenuHolder_mc);

      }

        • 1. Re: Drop-down menu text
          kglad Adobe Community Professional & MVP

          are your fonts embedded?

          • 2. Re: Drop-down menu text
            MatAut Level 1

            These were my original settings-

            flash text1.jpg

             

            Then I tried these settings and embedded fonts and it still doesn't work-

            flash text2.jpg

            • 3. Re: Drop-down menu text
              kglad Adobe Community Professional & MVP

              chosenMenu looks like an array of objects, not strings.  use the trace() function to confirm.

              • 4. Re: Drop-down menu text
                corey9

                have you tried using and referencing the text fields by giving them a Var name within the properties inspector rather than using an instance name? you would need to then also change your call from skinMenuTxt.text = xxxxxx to simply skinMenuTxt = xxxxxx. im not sure if that will make a difference in what you are trying to do, but it might be worth looking into.

                • 5. Re: Drop-down menu text
                  decpariem

                  Turn your textboxes into dynamic and assign them a name and a variable say this myname. Then fill them like this this.myname="brown" . It should work this way!

                  • 6. Re: Drop-down menu text
                    kglad Adobe Community Professional & MVP

                    you're bursting with unhelpful information today.

                    • 7. Re: Drop-down menu text
                      decpariem Level 1

                      Thought that we were discussing the problem! Don't understand why you are attacking to

                      me! Anyways! It's not even your broblems and you haven't even tried my alternative to see if it works!

                      • 8. Re: Drop-down menu text
                        Ned Murphy Adobe Community Professional & MVP

                        You shouldn't be offended. kGlad is just being honest with you (in all of the posts where he's commented to you)... you may be trying to help but you are not providing helpful information...

                         

                        this.myname="brown"

                         

                        will not work for a dynamic textfield with the name myname, but

                         

                        this.myname.text = "brown";

                         

                        would

                        • 9. Re: Drop-down menu text
                          decpariem Level 1

                          Everything I am suggesting just works fine for me.

                          Thisthis.myname="brown" works for me too! Why don't you test it? Do you want to send you the file?

                          • 10. Re: Drop-down menu text
                            Ned Murphy Adobe Community Professional & MVP

                            If you are using the var element of a textfield it can work, but it is not a reliable approach and can fail.  Assigning an instance name and using the text property is the proper approach.  The var aspect was removed in AS3 due to issues with it.

                             

                            Aside from that technicality, you were saying to change to using dynamic textfields--something that was already being used (in the proper way).

                            • 11. Re: Drop-down menu text
                              decpariem Level 1

                              Here is AS2 so you can't say that it's not working, when it has worked for me in more complicated projects!

                              He was using arrays, I suggested to assingn the values straight to the dynamic textfields,

                              That's all! Just gave an approach that is working for me! Didn't know that if I am not supposed to post anything under kglad.

                              • 12. Re: Drop-down menu text
                                kglad Adobe Community Professional & MVP

                                please stop posting in this thread.  i know you mean well but any post below this one is likely to further bury the cause and then the solution to this op's issue:

                                 


                                chosenMenu looks like an array of objects, not strings.  use the trace() function to confirm.

                                1 person found this helpful
                                • 13. Re: Drop-down menu text
                                  MatAut Level 1

                                  Thanks for the replies so far, sorry I haven't been quick to reply back. I traced chosenMenu and when I click on a drop down menu it lists each option of the submenu in the output-

                                  White, Brown, Tan, Olive

                                   

                                  I added a little to the code too so now there is 2 drop-downs.

                                  var menuButtons:Array = ["Body Type", "Skin Tone"];

                                  var subMenu1:Array = ["Small", "Medium", "Large"];

                                  var subMenu2:Array = ["White", "Brown", "Tan", "Olive"];

                                  var chosenMenu:Array = new Array();

                                  var subMenuOpened:Boolean = false;

                                  var whichSubMenu:Number = new Number();

                                  var currentPosition:Number = new Number();

                                  • 14. Re: Drop-down menu text
                                    kglad Adobe Community Professional & MVP

                                    what do you see in the output panel using the trace function below:

                                     


                                     

                                     

                                    var menuButtons:Array = ["Skin Tone"];

                                    var subMenu1:Array = ["White", "Brown", "Tan", "Olive"];

                                    var chosenMenu:Array = new Array();

                                    var subMenuOpened:Boolean = false;

                                    var whichSubMenu:Number = new Number();

                                    var currentPosition:Number = new Number();

                                     

                                    for (i=0; i<menuButtons.length; i++) {

                                                this.attachMovie("skinMenu", "menuButton"+i, this.getNextHighestDepth());

                                                this["menuButton"+i]._x = 131+(115*i);

                                                this["menuButton"+i]._y = 94.3;

                                                this["menuButton"+i].skinMenuTxt.text = menuButtons[i];

                                                this["menuButton"+i].onPress = function():Void {

                                                            whichSubMenu = Number(this._name.substr(-1, 1));

                                                            currentPosition = this._x;

                                                            if (!subMenuOpened) {

                                                                        subMenuOpened = true;

                                                                        openSubMenu(whichSubMenu, currentPosition);

                                                            } else {

                                                                        closeSubMenu();

                                                                        openSubMenu(whichSubMenu, currentPosition);

                                                            }

                                                };

                                    }

                                     

                                    function openSubMenu(whichSubMenu, currentPosition):Void {

                                                chosenMenu = eval("subMenu"+(whichSubMenu+1));

                                                for (j=0; j<chosenMenu.length; j++) {

                                                            this.createEmptyMovieClip("subMenuHolder_mc", this.getNextHighestDepth());

                                                            subMenuHolder_mc.attachMovie("skinMenu", "subMenuButton"+j, this.getNextHighestDepth());

                                                            subMenuHolder_mc["subMenuButton"+j]._x = currentPosition;

                                                            subMenuHolder_mc["subMenuButton"+j]._y = 94.3+(j*23);

                                                            subMenuHolder_mc["subMenuButton"+j].skinMenuTxt.text = chosenMenu[j];

                                     

                                    //////////////////////////////////////////////////

                                    trace(subMenuHolder_mc["subMenuButton"+j].skinMenuTxt+" "+subMenuHolder_mc["subMenuButton"+j].skinMenuTxt.text);

                                    /////////////////////////////////////////////////


                                                            subMenuHolder_mc["subMenuButton"+j].onRelease = subMenuHolder_mc["subMenuButton"+j].onReleaseOutside=function ():Void {

                                                                        closeSubMenu();

                                                            };

                                                }

                                    }

                                     

                                    function closeSubMenu():Void {

                                                removeMovieClip(subMenuHolder_mc);

                                    }

                                    1 person found this helpful
                                    • 15. Re: Drop-down menu text
                                      MatAut Level 1

                                      I get undefined, so when I click on the skin tone menu the output is this-

                                      White,Brown,Tan,Olive

                                      undefined undefined

                                      undefined undefined

                                      undefined undefined

                                      undefined undefined

                                       

                                      and for the body type menu-

                                      Small,Medium,Large

                                      undefined undefined

                                      undefined undefined

                                      undefined undefined

                                      • 16. Re: Drop-down menu text
                                        kglad Adobe Community Professional & MVP

                                         

                                         

                                        what do you see in the output panel using the trace function below:

                                         


                                         

                                         

                                        var menuButtons:Array = ["Skin Tone"];

                                        var subMenu1:Array = ["White", "Brown", "Tan", "Olive"];

                                        var chosenMenu:Array = new Array();

                                        var subMenuOpened:Boolean = false;

                                        var whichSubMenu:Number = new Number();

                                        var currentPosition:Number = new Number();

                                         

                                        for (i=0; i<menuButtons.length; i++) {

                                                    this.attachMovie("skinMenu", "menuButton"+i, this.getNextHighestDepth());

                                                    this["menuButton"+i]._x = 131+(115*i);

                                                    this["menuButton"+i]._y = 94.3;

                                                    this["menuButton"+i].skinMenuTxt.text = menuButtons[i];

                                                    this["menuButton"+i].onPress = function():Void {

                                                                whichSubMenu = Number(this._name.substr(-1, 1));

                                                                currentPosition = this._x;

                                                                if (!subMenuOpened) {

                                                                            subMenuOpened = true;

                                                                            openSubMenu(whichSubMenu, currentPosition);

                                                                } else {

                                                                            closeSubMenu();

                                                                            openSubMenu(whichSubMenu, currentPosition);

                                                                }

                                                    };

                                        }

                                         

                                        function openSubMenu(whichSubMenu, currentPosition):Void {

                                                    chosenMenu = eval("subMenu"+(whichSubMenu+1));

                                                    for (j=0; j<chosenMenu.length; j++) {

                                                                this.createEmptyMovieClip("subMenuHolder_mc", this.getNextHighestDepth());

                                                                subMenuHolder_mc.attachMovie("skinMenu", "subMenuButton"+j, this.getNextHighestDepth());

                                                                subMenuHolder_mc["subMenuButton"+j]._x = currentPosition;

                                                                subMenuHolder_mc["subMenuButton"+j]._y = 94.3+(j*23);

                                                                subMenuHolder_mc["subMenuButton"+j].skinMenuTxt.text = chosenMenu[j];

                                         

                                        //////////////////////////////////////////////////

                                        trace(subMenuHolder_mc+" "+subMenuHolder_mc["subMenuButton"+j]);

                                        /////////////////////////////////////////////////


                                                                subMenuHolder_mc["subMenuButton"+j].onRelease = subMenuHolder_mc["subMenuButton"+j].onReleaseOutside=function ():Void {

                                                                            closeSubMenu();

                                                                };

                                                    }

                                        }

                                         

                                        function closeSubMenu():Void {

                                                    removeMovieClip(subMenuHolder_mc);

                                        }

                                        • 17. Re: Drop-down menu text
                                          MatAut Level 1

                                          White,Brown,Tan,Olive

                                          _level0.subMenuHolder_mc _level0.subMenuHolder_mc.subMenuButton0

                                          _level0.subMenuHolder_mc _level0.subMenuHolder_mc.subMenuButton1

                                          _level0.subMenuHolder_mc _level0.subMenuHolder_mc.subMenuButton2

                                          _level0.subMenuHolder_mc _level0.subMenuHolder_mc.subMenuButton3

                                           

                                          Small,Medium,Large

                                          _level0.subMenuHolder_mc _level0.subMenuHolder_mc.subMenuButton0

                                          _level0.subMenuHolder_mc _level0.subMenuHolder_mc.subMenuButton1

                                          _level0.subMenuHolder_mc _level0.subMenuHolder_mc.subMenuButton2

                                          • 18. Re: Drop-down menu text
                                            kglad Adobe Community Professional & MVP

                                            then there's no textfield with instance name:

                                             

                                            skinMenuTxt

                                             

                                            in the movieclip with linkage id = skinMenu.

                                             

                                            fix that and retest.

                                            • 19. Re: Drop-down menu text
                                              MatAut Level 1

                                              Wow, stupid mistake, must've accidentally deleted that at some point. Thanks for your help!

                                              • 20. Re: Drop-down menu text
                                                kglad Adobe Community Professional & MVP

                                                you're welcome.