2 Replies Latest reply on Nov 13, 2006 12:31 PM by Emil_RT

    OOP and class methods

    Emil_RT Level 1
      I have an OOP problem. I'm new to OOP so it can be very easy or impossible. Either way - I don't know where to look for the answer.

      I have linked a class to a number of movieclips that i have on stage. The movieclips are clickable (buttons) and I want all buttons to be changed when I click one of them. E.g i want all to be dimmed if one is clicked. My problem is that i don't know how to call all my instaces of a class from one, or if it is possible!

      Do I make any sense? :)

        • 1. Re: OOP and class methods
          Level 7
          Typically, you would make a manager class that contains references to your
          button class. That way the manager can easily iterate over all instances of
          the button and do whatever it likes. You could do it as simple as - within
          the constructor of each button you can call a 'addInstance' method within
          the manager, where the manager would then add each instance to an instance
          array. Then, when a button is clicked send that button's instance to the
          manager - (btnClick method or something) and dim all but the instance being
          sent in...


          Dave -
          Head Developer
          Adobe Community Expert

          • 2. Re: OOP and class methods
            Emil_RT Level 1
            Ok, thank you for the anwer!

            So there is no way of a class to know how many instances that are vreated from it without saving references in an array?
            Couldn't I then use a static property to keep track of each button reference (in this case)? And have a method that itterates through the array?

            I dont really understand what you mean with manager class. Is that proper lingo? (so I can look it up).
            Do you mean that i should have a superclass?

            My real scenario is that I have a class linked to a couple of buttons. The class has onRollOver, onRollOut and onPress methods. Then I want to have an onDim method that is called when a button is clicked. I want this onDim function to be called on each button. (The clikced and the other ones). The reaseon is that I want to deactivate all buttons (MovieClips with button handlers) with:
            This because of a pop-up appears over all the buttons.