7 Replies Latest reply on Sep 28, 2008 4:57 PM by kglad

    Selecting Arrayed MCs for Hit Tests

    system_critical55
      Hi,

      I'm trying to make a bubble interface similar to Jonathan Harris' and Sep Kamvar's We Feel Fine. I've successfully got a dynamically generated number of
      circular movie clips floating around the stage. Their instance names are stored in an array. They
      are set to bounce around the stage indefinitely. Now I want to add some mouse interactivity. When
      I use a for loop to access the clips through the array and perform a hit test, the test is sucessful,
      but the resulting actions occur to all the bubble clips not just the one hit tested. Is there a way
      perhaps using "this" to modify the behavior of just one bubble clip. Here is the code for the hit testing.
      I apologize for the verbosity. I am still quite a novice and I'm sure there are more concise ways to
      write all of this. Thanks for the help and time.
        • 1. Re: Selecting Arrayed MCs for Hit Tests
          kglad Adobe Community Professional & MVP
          make your i variable local to mouseAttract and detDistanceMouse (and everywhere else you're calling another function in the middle of a for-loop whose counter is used in the other function).
          • 2. Re: Selecting Arrayed MCs for Hit Tests
            system_critical55 Level 1
            Hi,
            Thanks as usual for all the help. You helped me with a similar problem in a portfolio widget I was working on a few weeks ago. I guess it has still not sunk into my skull. I added a _root.bubbleArray .ivar = i; to my bubbulate (attach clip) function. This stores the original bubble's index within the array. So I assume in the function called by the hit test we want the bubble to be called by its ivar instead of I. I'm not sure how to integrate this into the hit test called function. Sorry for being a knuckle head, slow learner. Thank you very much for your time and help.
            • 3. Re: Selecting Arrayed MCs for Hit Tests
              system_critical55 Level 1
              Hi,
              Thanks as usual for all the help. You helped me with a similar problem in a portfolio widget I was working on a few weeks ago. I guess it has still not sunk into my skull. I added a _root.bubbleArray .ivar = i; to my bubbulate (attach clip) function. This stores the original bubble's index within the array. So I assume in the function called by the hit test we want the bubble to be called by its ivar instead of I. I'm not sure how to integrate this into the hit test called function. Sorry for being a knuckle head, slow learner. Thank you very much for your time and help.
              • 4. Re: Selecting Arrayed MCs for Hit Tests
                system_critical55 Level 1
                Hi,
                Thanks as usual for all the help. You helped me with a similar problem in a portfolio widget I was working on a few weeks ago. I guess it has still not sunk into my skull. I added a _root.bubbleArray .ivar = i; to my bubbulate (attach clip) function. This stores the original bubble's index within the array. So I assume in the function called by the hit test we want the bubble to be called by its ivar instead of I. I'm not sure how to integrate this into the hit test called function. Sorry for being a knuckle head, slow learner. Thank you very much for your time and help.
                • 5. Re: Selecting Arrayed MCs for Hit Tests
                  kglad Adobe Community Professional & MVP
                  it's hard to read your code (because you used array notation in your message - [ i ] - which this forum interprets as encoding for italic font), but it doesn't appear you changed i to be local. you must prefix its declaration with var:

                  for (var i=0; i<bNum; i++) {
                  • 6. Re: Selecting Arrayed MCs for Hit Tests
                    system_critical55 Level 1
                    Thanks, that got it. I appreciate the help as always.
                    • 7. Re: Selecting Arrayed MCs for Hit Tests
                      kglad Adobe Community Professional & MVP
                      you're welcome.