3 Replies Latest reply on Sep 8, 2009 5:11 AM by Ned Murphy

    Repeating buttons query.


      I've made a clock where each 'minute-marker' is a duplicate of a single button symbol. I want to attach different actionscript to each, but at the moment when i change the script on one copy, the script changes across them all, how do I prevent this from happening?


      Cheers, R.

        • 1. Re: Repeating buttons query.
          Ned Murphy Adobe Community Professional & MVP

          In what way are they duplicates of a sungle symbol... on the stage or in the library?  What is the nature of the code you want to change for each... is there some similarity such that the code would otherwise be the same across all of them?

          • 2. Re: Repeating buttons query.
            Rootle Level 1

            Well i have created the button in the library, then copied and pasted it many times onto the stage.


            The code I am using on each is very similar:






            on one button,






            on the next etc.


            wouldi need to attach the script to the movieclips individually rather than the buttons, then use instance names or something to assign each copy of the button to its corresponding movieclip?

            • 3. Re: Repeating buttons query.
              Ned Murphy Adobe Community Professional & MVP

              It sounds like what you really mean is that you have a movieclip that contains a button that you assign code to. This would explain your problem because having the code inside the movieclip applies to every copy of the movieclip, so if you change it for one it changes for all.  Had you actually just had the buttons with no containing movieclips, then you could have coded each one individually as you wish.


              What you started to describe could be an option for a solution.  What you could do is incorporate a variable into each movieclip and assign each one's value when the file starts (instance names needed for the mc's).  You could store the values needed in an array (or two, one for the mc names and one for the values assigned... though you could also use one array with objects in it that define the mc name and value in each object).


              So for the button code that would be inside the movieclips you would have something generic that all could still share but uses the variable to target different things....


              var myTarget; // assign it the actual object to simplify matters






              The way you have that coded in your response seems to indicate that the puff1, etc are in the same timeline as the button, which would have them inside the movieclips as well.  So I may be off in my thinking if the puffs are directly on the maintimeline and the buttons are not.