6 Replies Latest reply on Mar 9, 2007 9:04 PM by ggshow

    Cycle through button

    jgn2006
      Hi, how would I create a collection of my buttons so that I can step through it and perform action such as append "_btn" to all button names etc. How would I do that?
        • 1. Re: Cycle through button
          kglad Adobe Community Professional & MVP
          what are a few of the button names?
          • 2. Re: Cycle through button
            jgn2006 Level 1
            Currently the instances are just named 1,2,3,4 serially which I discovered does not work. I need to raname them to something like a1,a2 just so they work. Later, these numbers will be mapped to another scheme so I will have a translation table so for example button a1 will be named something like NT065
            • 3. Re: Cycle through button
              kglad Adobe Community Professional & MVP
              if you want to apply some code to buttons with instance names a1_btn, a2_btn etc, you can use:

              • 4. Re: Cycle through button
                jgn2006 Level 1
                This is nice to know. Thanks. So is it impossible to step through the buttons similar to the way you would do links=document.getElementByTagName('a') in DOM and then step through the variable links to process all links in turn by using a loop?
                • 5. Re: Cycle through button
                  kglad Adobe Community Professional & MVP
                  i don't know about DOM.
                  • 6. Re: Cycle through button
                    ggshow Level 2
                    DOM = document object models, allow us to access the contents via structured objects in the document.

                    In HTML, if you have a picture named "b1", then you can use document.getElementByTagName('b1') to refer to the picture.

                    In flash, if you have a movieclip/button instance called "b1",
                    to access the instance, we just say.... b1
                    or _level0.b1, _root.b1, _parent.b1 & etc.
                    this is how we access objects in flash.

                    to change the name of your buttons b1, b2, b3, you can try actionscripts below:

                    b1._name = "NT065";
                    b2._name = "NT066";
                    b3._name = "NT067";

                    this will change the name of your buttons to NT065, NT066, NT067.
                    You can also use a for loop to change the buttons name, using script below:

                    for(var i=1;i<=3;i++){
                    this["b"+i]._name = "NT0"+(64+i);
                    }


                    to expand all buttons name with "_btn", try script below:

                    for(var i=1;i<=3;i++){
                    this["b"+i]._name += "_btn";
                    }



                    Good Luck