35 Replies Latest reply on Sep 29, 2006 5:30 PM by Newsgroup_User

    Hittest and overlapping

    _eidolon
      Hi

      Im making a lemmings type game for flash
      Sometimes there are 2 or more MC's that are over lapping at a certain point, all of which are in a hitTest array example code attached. When the hittest is run i want to pass a variable to ONLY the top MC, any thoughts on how todo this?

      Justin
        • 1. Re: Hittest and overlapping
          Level 7

          "_eidolon" <webforumsuser@macromedia.com> wrote in message
          news:efk3fu$r9b$1@forums.macromedia.com...
          > Hi
          >
          > Im making a lemmings type game for flash
          > Sometimes there are 2 or more MC's that are over lapping at a certain
          > point,
          > all of which are in a hitTest array example code attached. When the
          > hittest is
          > run i want to pass a variable to ONLY the top MC, any thoughts on how
          > todo
          > this?
          >
          > Justin
          >
          > for (var i in charArray) {
          > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
          > _root[charArray
          ].currentAction = selectedAction;
          > }
          >

          Just an idea... but you could try something like:

          I assume charArray is an Array of MovieClip refs?

          NOTE ---- NOT TESTED

          var hit_mcs:Array = new Array();

          for (var i:Number = 0; i < charArray.length; i++) {
          if (charArray .hitTest(_xmouse, _ymouse, true)) {
          hit_mcs.push({mc:charArray
          , depth:charArray .getDepth()});
          }
          }

          function compareDepths(a:Object, b:Object) {
          var d1:Number = a.depth;
          var d2:Number = b.depth;
          if (d1 > d2) {
          return 1;
          } else if (d1 < d2) {
          return -1;
          } else {
          return 0;
          }
          }

          hit_mcs.sort(compareDepths);

          then hit_mcs[0].mc would be a ref to the top mc...


          • 2. Re: Hittest and overlapping
            Level 7

            "_eidolon" <webforumsuser@macromedia.com> wrote in message
            news:efk3fu$r9b$1@forums.macromedia.com...
            > Hi
            >
            > Im making a lemmings type game for flash
            > Sometimes there are 2 or more MC's that are over lapping at a certain
            > point,
            > all of which are in a hitTest array example code attached. When the
            > hittest is
            > run i want to pass a variable to ONLY the top MC, any thoughts on how
            > todo
            > this?
            >
            > Justin
            >
            > for (var i in charArray) {
            > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
            > _root[charArray
            ].currentAction = selectedAction;
            > }
            >

            Just an idea... but you could try something like:

            I assume charArray is an Array of MovieClip refs?

            NOTE ---- NOT TESTED

            var hit_mcs:Array = new Array();

            for (var i:Number = 0; i < charArray.length; i++) {
            if (charArray .hitTest(_xmouse, _ymouse, true)) {
            hit_mcs.push({mc:charArray
            , depth:charArray .getDepth()});
            }
            }

            function compareDepths(a:Object, b:Object) {
            var d1:Number = a.depth;
            var d2:Number = b.depth;
            if (d1 > d2) {
            return 1;
            } else if (d1 < d2) {
            return -1;
            } else {
            return 0;
            }
            }

            hit_mcs.sort(compareDepths);

            then hit_mcs[0].mc would be a ref to the top mc...


            • 3. Re: Hittest and overlapping
              kglad Adobe Community Professional & MVP
              there are quite a few ways to do that. because you're probably going to be running many hitTests, the best might be to reorder the elements of charArray() so the movieclip with the smallest depth is element zero, the next smallest is element one,..., the one with the greatest depth is the last.

              you could then use your current hitTest code and stop (break or return) with the first positive hitTest because that movieclip will have the greatest depth.
              • 4. Re: Hittest and overlapping
                Level 7

                "_eidolon" <webforumsuser@macromedia.com> wrote in message
                news:efk3fu$r9b$1@forums.macromedia.com...
                > Hi
                >
                > Im making a lemmings type game for flash
                > Sometimes there are 2 or more MC's that are over lapping at a certain
                > point,
                > all of which are in a hitTest array example code attached. When the
                > hittest is
                > run i want to pass a variable to ONLY the top MC, any thoughts on how
                > todo
                > this?
                >
                > Justin
                >
                > for (var i in charArray) {
                > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                > _root[charArray
                ].currentAction = selectedAction;
                > }
                >

                Just an idea... but you could try something like:

                I assume charArray is an Array of MovieClip refs?

                NOTE ---- NOT TESTED

                var hit_mcs:Array = new Array();

                for (var i:Number = 0; i < charArray.length; i++) {
                if (charArray .hitTest(_xmouse, _ymouse, true)) {
                hit_mcs.push({mc:charArray
                , depth:charArray .getDepth()});
                }
                }

                function compareDepths(a:Object, b:Object) {
                var d1:Number = a.depth;
                var d2:Number = b.depth;
                if (d1 > d2) {
                return 1;
                } else if (d1 < d2) {
                return -1;
                } else {
                return 0;
                }
                }

                hit_mcs.sort(compareDepths);

                then hit_mcs[0].mc would be a ref to the top mc...


                • 5. Re: Hittest and overlapping
                  Level 7

                  "_eidolon" <webforumsuser@macromedia.com> wrote in message
                  news:efk3fu$r9b$1@forums.macromedia.com...
                  > Hi
                  >
                  > Im making a lemmings type game for flash
                  > Sometimes there are 2 or more MC's that are over lapping at a certain
                  > point,
                  > all of which are in a hitTest array example code attached. When the
                  > hittest is
                  > run i want to pass a variable to ONLY the top MC, any thoughts on how
                  > todo
                  > this?
                  >
                  > Justin
                  >
                  > for (var i in charArray) {
                  > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                  > _root[charArray
                  ].currentAction = selectedAction;
                  > }
                  >

                  Just an idea... but you could try something like:

                  I assume charArray is an Array of MovieClip refs?

                  NOTE ---- NOT TESTED

                  var hit_mcs:Array = new Array();

                  for (var i:Number = 0; i < charArray.length; i++) {
                  if (charArray .hitTest(_xmouse, _ymouse, true)) {
                  hit_mcs.push({mc:charArray
                  , depth:charArray .getDepth()});
                  }
                  }

                  function compareDepths(a:Object, b:Object) {
                  var d1:Number = a.depth;
                  var d2:Number = b.depth;
                  if (d1 > d2) {
                  return 1;
                  } else if (d1 < d2) {
                  return -1;
                  } else {
                  return 0;
                  }
                  }

                  hit_mcs.sort(compareDepths);

                  then hit_mcs[0].mc would be a ref to the top mc...


                  • 6. Re: Hittest and overlapping
                    Level 7

                    "_eidolon" <webforumsuser@macromedia.com> wrote in message
                    news:efk3fu$r9b$1@forums.macromedia.com...
                    > Hi
                    >
                    > Im making a lemmings type game for flash
                    > Sometimes there are 2 or more MC's that are over lapping at a certain
                    > point,
                    > all of which are in a hitTest array example code attached. When the
                    > hittest is
                    > run i want to pass a variable to ONLY the top MC, any thoughts on how
                    > todo
                    > this?
                    >
                    > Justin
                    >
                    > for (var i in charArray) {
                    > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                    > _root[charArray
                    ].currentAction = selectedAction;
                    > }
                    >

                    Just an idea... but you could try something like:

                    I assume charArray is an Array of MovieClip refs?

                    NOTE ---- NOT TESTED

                    var hit_mcs:Array = new Array();

                    for (var i:Number = 0; i < charArray.length; i++) {
                    if (charArray .hitTest(_xmouse, _ymouse, true)) {
                    hit_mcs.push({mc:charArray
                    , depth:charArray .getDepth()});
                    }
                    }

                    function compareDepths(a:Object, b:Object) {
                    var d1:Number = a.depth;
                    var d2:Number = b.depth;
                    if (d1 > d2) {
                    return 1;
                    } else if (d1 < d2) {
                    return -1;
                    } else {
                    return 0;
                    }
                    }

                    hit_mcs.sort(compareDepths);

                    then hit_mcs[0].mc would be a ref to the top mc...


                    • 7. Re: Hittest and overlapping
                      Level 7

                      "_eidolon" <webforumsuser@macromedia.com> wrote in message
                      news:efk3fu$r9b$1@forums.macromedia.com...
                      > Hi
                      >
                      > Im making a lemmings type game for flash
                      > Sometimes there are 2 or more MC's that are over lapping at a certain
                      > point,
                      > all of which are in a hitTest array example code attached. When the
                      > hittest is
                      > run i want to pass a variable to ONLY the top MC, any thoughts on how
                      > todo
                      > this?
                      >
                      > Justin
                      >
                      > for (var i in charArray) {
                      > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                      > _root[charArray
                      ].currentAction = selectedAction;
                      > }
                      >

                      Just an idea... but you could try something like:

                      I assume charArray is an Array of MovieClip refs?

                      NOTE ---- NOT TESTED

                      var hit_mcs:Array = new Array();

                      for (var i:Number = 0; i < charArray.length; i++) {
                      if (charArray .hitTest(_xmouse, _ymouse, true)) {
                      hit_mcs.push({mc:charArray
                      , depth:charArray .getDepth()});
                      }
                      }

                      function compareDepths(a:Object, b:Object) {
                      var d1:Number = a.depth;
                      var d2:Number = b.depth;
                      if (d1 > d2) {
                      return 1;
                      } else if (d1 < d2) {
                      return -1;
                      } else {
                      return 0;
                      }
                      }

                      hit_mcs.sort(compareDepths);

                      then hit_mcs[0].mc would be a ref to the top mc...


                      • 8. Re: Hittest and overlapping
                        Level 7

                        "_eidolon" <webforumsuser@macromedia.com> wrote in message
                        news:efk3fu$r9b$1@forums.macromedia.com...
                        > Hi
                        >
                        > Im making a lemmings type game for flash
                        > Sometimes there are 2 or more MC's that are over lapping at a certain
                        > point,
                        > all of which are in a hitTest array example code attached. When the
                        > hittest is
                        > run i want to pass a variable to ONLY the top MC, any thoughts on how
                        > todo
                        > this?
                        >
                        > Justin
                        >
                        > for (var i in charArray) {
                        > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                        > _root[charArray
                        ].currentAction = selectedAction;
                        > }
                        >

                        Just an idea... but you could try something like:

                        I assume charArray is an Array of MovieClip refs?

                        NOTE ---- NOT TESTED

                        var hit_mcs:Array = new Array();

                        for (var i:Number = 0; i < charArray.length; i++) {
                        if (charArray .hitTest(_xmouse, _ymouse, true)) {
                        hit_mcs.push({mc:charArray
                        , depth:charArray .getDepth()});
                        }
                        }

                        function compareDepths(a:Object, b:Object) {
                        var d1:Number = a.depth;
                        var d2:Number = b.depth;
                        if (d1 > d2) {
                        return 1;
                        } else if (d1 < d2) {
                        return -1;
                        } else {
                        return 0;
                        }
                        }

                        hit_mcs.sort(compareDepths);

                        then hit_mcs[0].mc would be a ref to the top mc...


                        • 9. Re: Hittest and overlapping
                          Level 7

                          "_eidolon" <webforumsuser@macromedia.com> wrote in message
                          news:efk3fu$r9b$1@forums.macromedia.com...
                          > Hi
                          >
                          > Im making a lemmings type game for flash
                          > Sometimes there are 2 or more MC's that are over lapping at a certain
                          > point,
                          > all of which are in a hitTest array example code attached. When the
                          > hittest is
                          > run i want to pass a variable to ONLY the top MC, any thoughts on how
                          > todo
                          > this?
                          >
                          > Justin
                          >
                          > for (var i in charArray) {
                          > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                          > _root[charArray
                          ].currentAction = selectedAction;
                          > }
                          >

                          Just an idea... but you could try something like:

                          I assume charArray is an Array of MovieClip refs?

                          NOTE ---- NOT TESTED

                          var hit_mcs:Array = new Array();

                          for (var i:Number = 0; i < charArray.length; i++) {
                          if (charArray .hitTest(_xmouse, _ymouse, true)) {
                          hit_mcs.push({mc:charArray
                          , depth:charArray .getDepth()});
                          }
                          }

                          function compareDepths(a:Object, b:Object) {
                          var d1:Number = a.depth;
                          var d2:Number = b.depth;
                          if (d1 > d2) {
                          return 1;
                          } else if (d1 < d2) {
                          return -1;
                          } else {
                          return 0;
                          }
                          }

                          hit_mcs.sort(compareDepths);

                          then hit_mcs[0].mc would be a ref to the top mc...


                          • 10. Re: Hittest and overlapping
                            Level 7

                            "_eidolon" <webforumsuser@macromedia.com> wrote in message
                            news:efk3fu$r9b$1@forums.macromedia.com...
                            > Hi
                            >
                            > Im making a lemmings type game for flash
                            > Sometimes there are 2 or more MC's that are over lapping at a certain
                            > point,
                            > all of which are in a hitTest array example code attached. When the
                            > hittest is
                            > run i want to pass a variable to ONLY the top MC, any thoughts on how
                            > todo
                            > this?
                            >
                            > Justin
                            >
                            > for (var i in charArray) {
                            > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                            > _root[charArray
                            ].currentAction = selectedAction;
                            > }
                            >

                            Just an idea... but you could try something like:

                            I assume charArray is an Array of MovieClip refs?

                            NOTE ---- NOT TESTED

                            var hit_mcs:Array = new Array();

                            for (var i:Number = 0; i < charArray.length; i++) {
                            if (charArray .hitTest(_xmouse, _ymouse, true)) {
                            hit_mcs.push({mc:charArray
                            , depth:charArray .getDepth()});
                            }
                            }

                            function compareDepths(a:Object, b:Object) {
                            var d1:Number = a.depth;
                            var d2:Number = b.depth;
                            if (d1 > d2) {
                            return 1;
                            } else if (d1 < d2) {
                            return -1;
                            } else {
                            return 0;
                            }
                            }

                            hit_mcs.sort(compareDepths);

                            then hit_mcs[0].mc would be a ref to the top mc...


                            • 11. Re: Hittest and overlapping
                              Level 7

                              "_eidolon" <webforumsuser@macromedia.com> wrote in message
                              news:efk3fu$r9b$1@forums.macromedia.com...
                              > Hi
                              >
                              > Im making a lemmings type game for flash
                              > Sometimes there are 2 or more MC's that are over lapping at a certain
                              > point,
                              > all of which are in a hitTest array example code attached. When the
                              > hittest is
                              > run i want to pass a variable to ONLY the top MC, any thoughts on how
                              > todo
                              > this?
                              >
                              > Justin
                              >
                              > for (var i in charArray) {
                              > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                              > _root[charArray
                              ].currentAction = selectedAction;
                              > }
                              >

                              Just an idea... but you could try something like:

                              I assume charArray is an Array of MovieClip refs?

                              NOTE ---- NOT TESTED

                              var hit_mcs:Array = new Array();

                              for (var i:Number = 0; i < charArray.length; i++) {
                              if (charArray .hitTest(_xmouse, _ymouse, true)) {
                              hit_mcs.push({mc:charArray
                              , depth:charArray .getDepth()});
                              }
                              }

                              function compareDepths(a:Object, b:Object) {
                              var d1:Number = a.depth;
                              var d2:Number = b.depth;
                              if (d1 > d2) {
                              return 1;
                              } else if (d1 < d2) {
                              return -1;
                              } else {
                              return 0;
                              }
                              }

                              hit_mcs.sort(compareDepths);

                              then hit_mcs[0].mc would be a ref to the top mc...


                              • 12. Re: Hittest and overlapping
                                kglad Adobe Community Professional & MVP
                                sheesh, stop already.
                                • 13. Re: Hittest and overlapping
                                  Level 7

                                  "_eidolon" <webforumsuser@macromedia.com> wrote in message
                                  news:efk3fu$r9b$1@forums.macromedia.com...
                                  > Hi
                                  >
                                  > Im making a lemmings type game for flash
                                  > Sometimes there are 2 or more MC's that are over lapping at a certain
                                  > point,
                                  > all of which are in a hitTest array example code attached. When the
                                  > hittest is
                                  > run i want to pass a variable to ONLY the top MC, any thoughts on how
                                  > todo
                                  > this?
                                  >
                                  > Justin
                                  >
                                  > for (var i in charArray) {
                                  > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                                  > _root[charArray
                                  ].currentAction = selectedAction;
                                  > }
                                  >

                                  Just an idea... but you could try something like:

                                  I assume charArray is an Array of MovieClip refs?

                                  NOTE ---- NOT TESTED

                                  var hit_mcs:Array = new Array();

                                  for (var i:Number = 0; i < charArray.length; i++) {
                                  if (charArray .hitTest(_xmouse, _ymouse, true)) {
                                  hit_mcs.push({mc:charArray
                                  , depth:charArray .getDepth()});
                                  }
                                  }

                                  function compareDepths(a:Object, b:Object) {
                                  var d1:Number = a.depth;
                                  var d2:Number = b.depth;
                                  if (d1 > d2) {
                                  return 1;
                                  } else if (d1 < d2) {
                                  return -1;
                                  } else {
                                  return 0;
                                  }
                                  }

                                  hit_mcs.sort(compareDepths);

                                  then hit_mcs[0].mc would be a ref to the top mc...


                                  • 14. Re: Hittest and overlapping
                                    Level 7

                                    "_eidolon" <webforumsuser@macromedia.com> wrote in message
                                    news:efk3fu$r9b$1@forums.macromedia.com...
                                    > Hi
                                    >
                                    > Im making a lemmings type game for flash
                                    > Sometimes there are 2 or more MC's that are over lapping at a certain
                                    > point,
                                    > all of which are in a hitTest array example code attached. When the
                                    > hittest is
                                    > run i want to pass a variable to ONLY the top MC, any thoughts on how
                                    > todo
                                    > this?
                                    >
                                    > Justin
                                    >
                                    > for (var i in charArray) {
                                    > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                                    > _root[charArray
                                    ].currentAction = selectedAction;
                                    > }
                                    >

                                    Just an idea... but you could try something like:

                                    I assume charArray is an Array of MovieClip refs?

                                    NOTE ---- NOT TESTED

                                    var hit_mcs:Array = new Array();

                                    for (var i:Number = 0; i < charArray.length; i++) {
                                    if (charArray .hitTest(_xmouse, _ymouse, true)) {
                                    hit_mcs.push({mc:charArray
                                    , depth:charArray .getDepth()});
                                    }
                                    }

                                    function compareDepths(a:Object, b:Object) {
                                    var d1:Number = a.depth;
                                    var d2:Number = b.depth;
                                    if (d1 > d2) {
                                    return 1;
                                    } else if (d1 < d2) {
                                    return -1;
                                    } else {
                                    return 0;
                                    }
                                    }

                                    hit_mcs.sort(compareDepths);

                                    then hit_mcs[0].mc would be a ref to the top mc...


                                    • 15. Re: Hittest and overlapping
                                      Level 7

                                      "_eidolon" <webforumsuser@macromedia.com> wrote in message
                                      news:efk3fu$r9b$1@forums.macromedia.com...
                                      > Hi
                                      >
                                      > Im making a lemmings type game for flash
                                      > Sometimes there are 2 or more MC's that are over lapping at a certain
                                      > point,
                                      > all of which are in a hitTest array example code attached. When the
                                      > hittest is
                                      > run i want to pass a variable to ONLY the top MC, any thoughts on how
                                      > todo
                                      > this?
                                      >
                                      > Justin
                                      >
                                      > for (var i in charArray) {
                                      > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                                      > _root[charArray
                                      ].currentAction = selectedAction;
                                      > }
                                      >

                                      Just an idea... but you could try something like:

                                      I assume charArray is an Array of MovieClip refs?

                                      NOTE ---- NOT TESTED

                                      var hit_mcs:Array = new Array();

                                      for (var i:Number = 0; i < charArray.length; i++) {
                                      if (charArray .hitTest(_xmouse, _ymouse, true)) {
                                      hit_mcs.push({mc:charArray
                                      , depth:charArray .getDepth()});
                                      }
                                      }

                                      function compareDepths(a:Object, b:Object) {
                                      var d1:Number = a.depth;
                                      var d2:Number = b.depth;
                                      if (d1 > d2) {
                                      return 1;
                                      } else if (d1 < d2) {
                                      return -1;
                                      } else {
                                      return 0;
                                      }
                                      }

                                      hit_mcs.sort(compareDepths);

                                      then hit_mcs[0].mc would be a ref to the top mc...


                                      • 16. Re: Hittest and overlapping
                                        Level 7

                                        "_eidolon" <webforumsuser@macromedia.com> wrote in message
                                        news:efk3fu$r9b$1@forums.macromedia.com...
                                        > Hi
                                        >
                                        > Im making a lemmings type game for flash
                                        > Sometimes there are 2 or more MC's that are over lapping at a certain
                                        > point,
                                        > all of which are in a hitTest array example code attached. When the
                                        > hittest is
                                        > run i want to pass a variable to ONLY the top MC, any thoughts on how
                                        > todo
                                        > this?
                                        >
                                        > Justin
                                        >
                                        > for (var i in charArray) {
                                        > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                                        > _root[charArray
                                        ].currentAction = selectedAction;
                                        > }
                                        >

                                        Just an idea... but you could try something like:

                                        I assume charArray is an Array of MovieClip refs?

                                        NOTE ---- NOT TESTED

                                        var hit_mcs:Array = new Array();

                                        for (var i:Number = 0; i < charArray.length; i++) {
                                        if (charArray .hitTest(_xmouse, _ymouse, true)) {
                                        hit_mcs.push({mc:charArray
                                        , depth:charArray .getDepth()});
                                        }
                                        }

                                        function compareDepths(a:Object, b:Object) {
                                        var d1:Number = a.depth;
                                        var d2:Number = b.depth;
                                        if (d1 > d2) {
                                        return 1;
                                        } else if (d1 < d2) {
                                        return -1;
                                        } else {
                                        return 0;
                                        }
                                        }

                                        hit_mcs.sort(compareDepths);

                                        then hit_mcs[0].mc would be a ref to the top mc...


                                        • 17. Re: Hittest and overlapping
                                          Level 7

                                          "_eidolon" <webforumsuser@macromedia.com> wrote in message
                                          news:efk3fu$r9b$1@forums.macromedia.com...
                                          > Hi
                                          >
                                          > Im making a lemmings type game for flash
                                          > Sometimes there are 2 or more MC's that are over lapping at a certain
                                          > point,
                                          > all of which are in a hitTest array example code attached. When the
                                          > hittest is
                                          > run i want to pass a variable to ONLY the top MC, any thoughts on how
                                          > todo
                                          > this?
                                          >
                                          > Justin
                                          >
                                          > for (var i in charArray) {
                                          > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                                          > _root[charArray
                                          ].currentAction = selectedAction;
                                          > }
                                          >

                                          Just an idea... but you could try something like:

                                          I assume charArray is an Array of MovieClip refs?

                                          NOTE ---- NOT TESTED

                                          var hit_mcs:Array = new Array();

                                          for (var i:Number = 0; i < charArray.length; i++) {
                                          if (charArray .hitTest(_xmouse, _ymouse, true)) {
                                          hit_mcs.push({mc:charArray
                                          , depth:charArray .getDepth()});
                                          }
                                          }

                                          function compareDepths(a:Object, b:Object) {
                                          var d1:Number = a.depth;
                                          var d2:Number = b.depth;
                                          if (d1 > d2) {
                                          return 1;
                                          } else if (d1 < d2) {
                                          return -1;
                                          } else {
                                          return 0;
                                          }
                                          }

                                          hit_mcs.sort(compareDepths);

                                          then hit_mcs[0].mc would be a ref to the top mc...


                                          • 18. Re: Hittest and overlapping
                                            Level 7

                                            "_eidolon" <webforumsuser@macromedia.com> wrote in message
                                            news:efk3fu$r9b$1@forums.macromedia.com...
                                            > Hi
                                            >
                                            > Im making a lemmings type game for flash
                                            > Sometimes there are 2 or more MC's that are over lapping at a certain
                                            > point,
                                            > all of which are in a hitTest array example code attached. When the
                                            > hittest is
                                            > run i want to pass a variable to ONLY the top MC, any thoughts on how
                                            > todo
                                            > this?
                                            >
                                            > Justin
                                            >
                                            > for (var i in charArray) {
                                            > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                                            > _root[charArray
                                            ].currentAction = selectedAction;
                                            > }
                                            >

                                            Just an idea... but you could try something like:

                                            I assume charArray is an Array of MovieClip refs?

                                            NOTE ---- NOT TESTED

                                            var hit_mcs:Array = new Array();

                                            for (var i:Number = 0; i < charArray.length; i++) {
                                            if (charArray .hitTest(_xmouse, _ymouse, true)) {
                                            hit_mcs.push({mc:charArray
                                            , depth:charArray .getDepth()});
                                            }
                                            }

                                            function compareDepths(a:Object, b:Object) {
                                            var d1:Number = a.depth;
                                            var d2:Number = b.depth;
                                            if (d1 > d2) {
                                            return 1;
                                            } else if (d1 < d2) {
                                            return -1;
                                            } else {
                                            return 0;
                                            }
                                            }

                                            hit_mcs.sort(compareDepths);

                                            then hit_mcs[0].mc would be a ref to the top mc...


                                            • 19. Re: Hittest and overlapping
                                              Level 7

                                              "_eidolon" <webforumsuser@macromedia.com> wrote in message
                                              news:efk3fu$r9b$1@forums.macromedia.com...
                                              > Hi
                                              >
                                              > Im making a lemmings type game for flash
                                              > Sometimes there are 2 or more MC's that are over lapping at a certain
                                              > point,
                                              > all of which are in a hitTest array example code attached. When the
                                              > hittest is
                                              > run i want to pass a variable to ONLY the top MC, any thoughts on how
                                              > todo
                                              > this?
                                              >
                                              > Justin
                                              >
                                              > for (var i in charArray) {
                                              > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                                              > _root[charArray
                                              ].currentAction = selectedAction;
                                              > }
                                              >

                                              Just an idea... but you could try something like:

                                              I assume charArray is an Array of MovieClip refs?

                                              NOTE ---- NOT TESTED

                                              var hit_mcs:Array = new Array();

                                              for (var i:Number = 0; i < charArray.length; i++) {
                                              if (charArray .hitTest(_xmouse, _ymouse, true)) {
                                              hit_mcs.push({mc:charArray
                                              , depth:charArray .getDepth()});
                                              }
                                              }

                                              function compareDepths(a:Object, b:Object) {
                                              var d1:Number = a.depth;
                                              var d2:Number = b.depth;
                                              if (d1 > d2) {
                                              return 1;
                                              } else if (d1 < d2) {
                                              return -1;
                                              } else {
                                              return 0;
                                              }
                                              }

                                              hit_mcs.sort(compareDepths);

                                              then hit_mcs[0].mc would be a ref to the top mc...


                                              • 20. Re: Hittest and overlapping
                                                Level 7

                                                "_eidolon" <webforumsuser@macromedia.com> wrote in message
                                                news:efk3fu$r9b$1@forums.macromedia.com...
                                                > Hi
                                                >
                                                > Im making a lemmings type game for flash
                                                > Sometimes there are 2 or more MC's that are over lapping at a certain
                                                > point,
                                                > all of which are in a hitTest array example code attached. When the
                                                > hittest is
                                                > run i want to pass a variable to ONLY the top MC, any thoughts on how
                                                > todo
                                                > this?
                                                >
                                                > Justin
                                                >
                                                > for (var i in charArray) {
                                                > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                                                > _root[charArray
                                                ].currentAction = selectedAction;
                                                > }
                                                >

                                                Just an idea... but you could try something like:

                                                I assume charArray is an Array of MovieClip refs?

                                                NOTE ---- NOT TESTED

                                                var hit_mcs:Array = new Array();

                                                for (var i:Number = 0; i < charArray.length; i++) {
                                                if (charArray .hitTest(_xmouse, _ymouse, true)) {
                                                hit_mcs.push({mc:charArray
                                                , depth:charArray .getDepth()});
                                                }
                                                }

                                                function compareDepths(a:Object, b:Object) {
                                                var d1:Number = a.depth;
                                                var d2:Number = b.depth;
                                                if (d1 > d2) {
                                                return 1;
                                                } else if (d1 < d2) {
                                                return -1;
                                                } else {
                                                return 0;
                                                }
                                                }

                                                hit_mcs.sort(compareDepths);

                                                then hit_mcs[0].mc would be a ref to the top mc...


                                                • 21. Re: Hittest and overlapping
                                                  Level 7

                                                  "_eidolon" <webforumsuser@macromedia.com> wrote in message
                                                  news:efk3fu$r9b$1@forums.macromedia.com...
                                                  > Hi
                                                  >
                                                  > Im making a lemmings type game for flash
                                                  > Sometimes there are 2 or more MC's that are over lapping at a certain
                                                  > point,
                                                  > all of which are in a hitTest array example code attached. When the
                                                  > hittest is
                                                  > run i want to pass a variable to ONLY the top MC, any thoughts on how
                                                  > todo
                                                  > this?
                                                  >
                                                  > Justin
                                                  >
                                                  > for (var i in charArray) {
                                                  > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                                                  > _root[charArray
                                                  ].currentAction = selectedAction;
                                                  > }
                                                  >

                                                  Just an idea... but you could try something like:

                                                  I assume charArray is an Array of MovieClip refs?

                                                  NOTE ---- NOT TESTED

                                                  var hit_mcs:Array = new Array();

                                                  for (var i:Number = 0; i < charArray.length; i++) {
                                                  if (charArray .hitTest(_xmouse, _ymouse, true)) {
                                                  hit_mcs.push({mc:charArray
                                                  , depth:charArray .getDepth()});
                                                  }
                                                  }

                                                  function compareDepths(a:Object, b:Object) {
                                                  var d1:Number = a.depth;
                                                  var d2:Number = b.depth;
                                                  if (d1 > d2) {
                                                  return 1;
                                                  } else if (d1 < d2) {
                                                  return -1;
                                                  } else {
                                                  return 0;
                                                  }
                                                  }

                                                  hit_mcs.sort(compareDepths);

                                                  then hit_mcs[0].mc would be a ref to the top mc...


                                                  • 22. Re: Hittest and overlapping
                                                    Level 7

                                                    "_eidolon" <webforumsuser@macromedia.com> wrote in message
                                                    news:efk3fu$r9b$1@forums.macromedia.com...
                                                    > Hi
                                                    >
                                                    > Im making a lemmings type game for flash
                                                    > Sometimes there are 2 or more MC's that are over lapping at a certain
                                                    > point,
                                                    > all of which are in a hitTest array example code attached. When the
                                                    > hittest is
                                                    > run i want to pass a variable to ONLY the top MC, any thoughts on how
                                                    > todo
                                                    > this?
                                                    >
                                                    > Justin
                                                    >
                                                    > for (var i in charArray) {
                                                    > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                                                    > _root[charArray
                                                    ].currentAction = selectedAction;
                                                    > }
                                                    >

                                                    Just an idea... but you could try something like:

                                                    I assume charArray is an Array of MovieClip refs?

                                                    NOTE ---- NOT TESTED

                                                    var hit_mcs:Array = new Array();

                                                    for (var i:Number = 0; i < charArray.length; i++) {
                                                    if (charArray .hitTest(_xmouse, _ymouse, true)) {
                                                    hit_mcs.push({mc:charArray
                                                    , depth:charArray .getDepth()});
                                                    }
                                                    }

                                                    function compareDepths(a:Object, b:Object) {
                                                    var d1:Number = a.depth;
                                                    var d2:Number = b.depth;
                                                    if (d1 > d2) {
                                                    return 1;
                                                    } else if (d1 < d2) {
                                                    return -1;
                                                    } else {
                                                    return 0;
                                                    }
                                                    }

                                                    hit_mcs.sort(compareDepths);

                                                    then hit_mcs[0].mc would be a ref to the top mc...


                                                    • 23. Re: Hittest and overlapping
                                                      Level 7

                                                      "_eidolon" <webforumsuser@macromedia.com> wrote in message
                                                      news:efk3fu$r9b$1@forums.macromedia.com...
                                                      > Hi
                                                      >
                                                      > Im making a lemmings type game for flash
                                                      > Sometimes there are 2 or more MC's that are over lapping at a certain
                                                      > point,
                                                      > all of which are in a hitTest array example code attached. When the
                                                      > hittest is
                                                      > run i want to pass a variable to ONLY the top MC, any thoughts on how
                                                      > todo
                                                      > this?
                                                      >
                                                      > Justin
                                                      >
                                                      > for (var i in charArray) {
                                                      > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                                                      > _root[charArray
                                                      ].currentAction = selectedAction;
                                                      > }
                                                      >

                                                      Just an idea... but you could try something like:

                                                      I assume charArray is an Array of MovieClip refs?

                                                      NOTE ---- NOT TESTED

                                                      var hit_mcs:Array = new Array();

                                                      for (var i:Number = 0; i < charArray.length; i++) {
                                                      if (charArray .hitTest(_xmouse, _ymouse, true)) {
                                                      hit_mcs.push({mc:charArray
                                                      , depth:charArray .getDepth()});
                                                      }
                                                      }

                                                      function compareDepths(a:Object, b:Object) {
                                                      var d1:Number = a.depth;
                                                      var d2:Number = b.depth;
                                                      if (d1 > d2) {
                                                      return 1;
                                                      } else if (d1 < d2) {
                                                      return -1;
                                                      } else {
                                                      return 0;
                                                      }
                                                      }

                                                      hit_mcs.sort(compareDepths);

                                                      then hit_mcs[0].mc would be a ref to the top mc...


                                                      • 24. Re: Hittest and overlapping
                                                        Level 7

                                                        "_eidolon" <webforumsuser@macromedia.com> wrote in message
                                                        news:efk3fu$r9b$1@forums.macromedia.com...
                                                        > Hi
                                                        >
                                                        > Im making a lemmings type game for flash
                                                        > Sometimes there are 2 or more MC's that are over lapping at a certain
                                                        > point,
                                                        > all of which are in a hitTest array example code attached. When the
                                                        > hittest is
                                                        > run i want to pass a variable to ONLY the top MC, any thoughts on how
                                                        > todo
                                                        > this?
                                                        >
                                                        > Justin
                                                        >
                                                        > for (var i in charArray) {
                                                        > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                                                        > _root[charArray
                                                        ].currentAction = selectedAction;
                                                        > }
                                                        >

                                                        Just an idea... but you could try something like:

                                                        I assume charArray is an Array of MovieClip refs?

                                                        NOTE ---- NOT TESTED

                                                        var hit_mcs:Array = new Array();

                                                        for (var i:Number = 0; i < charArray.length; i++) {
                                                        if (charArray .hitTest(_xmouse, _ymouse, true)) {
                                                        hit_mcs.push({mc:charArray
                                                        , depth:charArray .getDepth()});
                                                        }
                                                        }

                                                        function compareDepths(a:Object, b:Object) {
                                                        var d1:Number = a.depth;
                                                        var d2:Number = b.depth;
                                                        if (d1 > d2) {
                                                        return 1;
                                                        } else if (d1 < d2) {
                                                        return -1;
                                                        } else {
                                                        return 0;
                                                        }
                                                        }

                                                        hit_mcs.sort(compareDepths);

                                                        then hit_mcs[0].mc would be a ref to the top mc...


                                                        • 25. Re: Hittest and overlapping
                                                          Level 7

                                                          "_eidolon" <webforumsuser@macromedia.com> wrote in message
                                                          news:efk3fu$r9b$1@forums.macromedia.com...
                                                          > Hi
                                                          >
                                                          > Im making a lemmings type game for flash
                                                          > Sometimes there are 2 or more MC's that are over lapping at a certain
                                                          > point,
                                                          > all of which are in a hitTest array example code attached. When the
                                                          > hittest is
                                                          > run i want to pass a variable to ONLY the top MC, any thoughts on how
                                                          > todo
                                                          > this?
                                                          >
                                                          > Justin
                                                          >
                                                          > for (var i in charArray) {
                                                          > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                                                          > _root[charArray
                                                          ].currentAction = selectedAction;
                                                          > }
                                                          >

                                                          Just an idea... but you could try something like:

                                                          I assume charArray is an Array of MovieClip refs?

                                                          NOTE ---- NOT TESTED

                                                          var hit_mcs:Array = new Array();

                                                          for (var i:Number = 0; i < charArray.length; i++) {
                                                          if (charArray .hitTest(_xmouse, _ymouse, true)) {
                                                          hit_mcs.push({mc:charArray
                                                          , depth:charArray .getDepth()});
                                                          }
                                                          }

                                                          function compareDepths(a:Object, b:Object) {
                                                          var d1:Number = a.depth;
                                                          var d2:Number = b.depth;
                                                          if (d1 > d2) {
                                                          return 1;
                                                          } else if (d1 < d2) {
                                                          return -1;
                                                          } else {
                                                          return 0;
                                                          }
                                                          }

                                                          hit_mcs.sort(compareDepths);

                                                          then hit_mcs[0].mc would be a ref to the top mc...


                                                          • 26. Re: Hittest and overlapping
                                                            Level 7

                                                            "_eidolon" <webforumsuser@macromedia.com> wrote in message
                                                            news:efk3fu$r9b$1@forums.macromedia.com...
                                                            > Hi
                                                            >
                                                            > Im making a lemmings type game for flash
                                                            > Sometimes there are 2 or more MC's that are over lapping at a certain
                                                            > point,
                                                            > all of which are in a hitTest array example code attached. When the
                                                            > hittest is
                                                            > run i want to pass a variable to ONLY the top MC, any thoughts on how
                                                            > todo
                                                            > this?
                                                            >
                                                            > Justin
                                                            >
                                                            > for (var i in charArray) {
                                                            > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                                                            > _root[charArray
                                                            ].currentAction = selectedAction;
                                                            > }
                                                            >

                                                            Just an idea... but you could try something like:

                                                            I assume charArray is an Array of MovieClip refs?

                                                            NOTE ---- NOT TESTED

                                                            var hit_mcs:Array = new Array();

                                                            for (var i:Number = 0; i < charArray.length; i++) {
                                                            if (charArray .hitTest(_xmouse, _ymouse, true)) {
                                                            hit_mcs.push({mc:charArray
                                                            , depth:charArray .getDepth()});
                                                            }
                                                            }

                                                            function compareDepths(a:Object, b:Object) {
                                                            var d1:Number = a.depth;
                                                            var d2:Number = b.depth;
                                                            if (d1 > d2) {
                                                            return 1;
                                                            } else if (d1 < d2) {
                                                            return -1;
                                                            } else {
                                                            return 0;
                                                            }
                                                            }

                                                            hit_mcs.sort(compareDepths);

                                                            then hit_mcs[0].mc would be a ref to the top mc...


                                                            • 27. Re: Hittest and overlapping
                                                              Level 7

                                                              "_eidolon" <webforumsuser@macromedia.com> wrote in message
                                                              news:efk3fu$r9b$1@forums.macromedia.com...
                                                              > Hi
                                                              >
                                                              > Im making a lemmings type game for flash
                                                              > Sometimes there are 2 or more MC's that are over lapping at a certain
                                                              > point,
                                                              > all of which are in a hitTest array example code attached. When the
                                                              > hittest is
                                                              > run i want to pass a variable to ONLY the top MC, any thoughts on how
                                                              > todo
                                                              > this?
                                                              >
                                                              > Justin
                                                              >
                                                              > for (var i in charArray) {
                                                              > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                                                              > _root[charArray
                                                              ].currentAction = selectedAction;
                                                              > }
                                                              >

                                                              Just an idea... but you could try something like:

                                                              I assume charArray is an Array of MovieClip refs?

                                                              NOTE ---- NOT TESTED

                                                              var hit_mcs:Array = new Array();

                                                              for (var i:Number = 0; i < charArray.length; i++) {
                                                              if (charArray .hitTest(_xmouse, _ymouse, true)) {
                                                              hit_mcs.push({mc:charArray
                                                              , depth:charArray .getDepth()});
                                                              }
                                                              }

                                                              function compareDepths(a:Object, b:Object) {
                                                              var d1:Number = a.depth;
                                                              var d2:Number = b.depth;
                                                              if (d1 > d2) {
                                                              return 1;
                                                              } else if (d1 < d2) {
                                                              return -1;
                                                              } else {
                                                              return 0;
                                                              }
                                                              }

                                                              hit_mcs.sort(compareDepths);

                                                              then hit_mcs[0].mc would be a ref to the top mc...


                                                              • 28. Re: Hittest and overlapping
                                                                Level 7

                                                                "_eidolon" <webforumsuser@macromedia.com> wrote in message
                                                                news:efk3fu$r9b$1@forums.macromedia.com...
                                                                > Hi
                                                                >
                                                                > Im making a lemmings type game for flash
                                                                > Sometimes there are 2 or more MC's that are over lapping at a certain
                                                                > point,
                                                                > all of which are in a hitTest array example code attached. When the
                                                                > hittest is
                                                                > run i want to pass a variable to ONLY the top MC, any thoughts on how
                                                                > todo
                                                                > this?
                                                                >
                                                                > Justin
                                                                >
                                                                > for (var i in charArray) {
                                                                > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                                                                > _root[charArray
                                                                ].currentAction = selectedAction;
                                                                > }
                                                                >

                                                                Just an idea... but you could try something like:

                                                                I assume charArray is an Array of MovieClip refs?

                                                                NOTE ---- NOT TESTED

                                                                var hit_mcs:Array = new Array();

                                                                for (var i:Number = 0; i < charArray.length; i++) {
                                                                if (charArray .hitTest(_xmouse, _ymouse, true)) {
                                                                hit_mcs.push({mc:charArray
                                                                , depth:charArray .getDepth()});
                                                                }
                                                                }

                                                                function compareDepths(a:Object, b:Object) {
                                                                var d1:Number = a.depth;
                                                                var d2:Number = b.depth;
                                                                if (d1 > d2) {
                                                                return 1;
                                                                } else if (d1 < d2) {
                                                                return -1;
                                                                } else {
                                                                return 0;
                                                                }
                                                                }

                                                                hit_mcs.sort(compareDepths);

                                                                then hit_mcs[0].mc would be a ref to the top mc...


                                                                • 29. Re: Hittest and overlapping
                                                                  Level 7

                                                                  "_eidolon" <webforumsuser@macromedia.com> wrote in message
                                                                  news:efk3fu$r9b$1@forums.macromedia.com...
                                                                  > Hi
                                                                  >
                                                                  > Im making a lemmings type game for flash
                                                                  > Sometimes there are 2 or more MC's that are over lapping at a certain
                                                                  > point,
                                                                  > all of which are in a hitTest array example code attached. When the
                                                                  > hittest is
                                                                  > run i want to pass a variable to ONLY the top MC, any thoughts on how
                                                                  > todo
                                                                  > this?
                                                                  >
                                                                  > Justin
                                                                  >
                                                                  > for (var i in charArray) {
                                                                  > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                                                                  > _root[charArray
                                                                  ].currentAction = selectedAction;
                                                                  > }
                                                                  >

                                                                  Just an idea... but you could try something like:

                                                                  I assume charArray is an Array of MovieClip refs?

                                                                  NOTE ---- NOT TESTED

                                                                  var hit_mcs:Array = new Array();

                                                                  for (var i:Number = 0; i < charArray.length; i++) {
                                                                  if (charArray .hitTest(_xmouse, _ymouse, true)) {
                                                                  hit_mcs.push({mc:charArray
                                                                  , depth:charArray .getDepth()});
                                                                  }
                                                                  }

                                                                  function compareDepths(a:Object, b:Object) {
                                                                  var d1:Number = a.depth;
                                                                  var d2:Number = b.depth;
                                                                  if (d1 > d2) {
                                                                  return 1;
                                                                  } else if (d1 < d2) {
                                                                  return -1;
                                                                  } else {
                                                                  return 0;
                                                                  }
                                                                  }

                                                                  hit_mcs.sort(compareDepths);

                                                                  then hit_mcs[0].mc would be a ref to the top mc...


                                                                  • 30. Re: Hittest and overlapping
                                                                    Level 7

                                                                    "_eidolon" <webforumsuser@macromedia.com> wrote in message
                                                                    news:efk3fu$r9b$1@forums.macromedia.com...
                                                                    > Hi
                                                                    >
                                                                    > Im making a lemmings type game for flash
                                                                    > Sometimes there are 2 or more MC's that are over lapping at a certain
                                                                    > point,
                                                                    > all of which are in a hitTest array example code attached. When the
                                                                    > hittest is
                                                                    > run i want to pass a variable to ONLY the top MC, any thoughts on how
                                                                    > todo
                                                                    > this?
                                                                    >
                                                                    > Justin
                                                                    >
                                                                    > for (var i in charArray) {
                                                                    > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                                                                    > _root[charArray
                                                                    ].currentAction = selectedAction;
                                                                    > }
                                                                    >

                                                                    Just an idea... but you could try something like:

                                                                    I assume charArray is an Array of MovieClip refs?

                                                                    NOTE ---- NOT TESTED

                                                                    var hit_mcs:Array = new Array();

                                                                    for (var i:Number = 0; i < charArray.length; i++) {
                                                                    if (charArray .hitTest(_xmouse, _ymouse, true)) {
                                                                    hit_mcs.push({mc:charArray
                                                                    , depth:charArray .getDepth()});
                                                                    }
                                                                    }

                                                                    function compareDepths(a:Object, b:Object) {
                                                                    var d1:Number = a.depth;
                                                                    var d2:Number = b.depth;
                                                                    if (d1 > d2) {
                                                                    return 1;
                                                                    } else if (d1 < d2) {
                                                                    return -1;
                                                                    } else {
                                                                    return 0;
                                                                    }
                                                                    }

                                                                    hit_mcs.sort(compareDepths);

                                                                    then hit_mcs[0].mc would be a ref to the top mc...


                                                                    • 31. Re: Hittest and overlapping
                                                                      Level 7

                                                                      "_eidolon" <webforumsuser@macromedia.com> wrote in message
                                                                      news:efk3fu$r9b$1@forums.macromedia.com...
                                                                      > Hi
                                                                      >
                                                                      > Im making a lemmings type game for flash
                                                                      > Sometimes there are 2 or more MC's that are over lapping at a certain
                                                                      > point,
                                                                      > all of which are in a hitTest array example code attached. When the
                                                                      > hittest is
                                                                      > run i want to pass a variable to ONLY the top MC, any thoughts on how
                                                                      > todo
                                                                      > this?
                                                                      >
                                                                      > Justin
                                                                      >
                                                                      > for (var i in charArray) {
                                                                      > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                                                                      > _root[charArray
                                                                      ].currentAction = selectedAction;
                                                                      > }
                                                                      >

                                                                      Just an idea... but you could try something like:

                                                                      I assume charArray is an Array of MovieClip refs?

                                                                      NOTE ---- NOT TESTED

                                                                      var hit_mcs:Array = new Array();

                                                                      for (var i:Number = 0; i < charArray.length; i++) {
                                                                      if (charArray .hitTest(_xmouse, _ymouse, true)) {
                                                                      hit_mcs.push({mc:charArray
                                                                      , depth:charArray .getDepth()});
                                                                      }
                                                                      }

                                                                      function compareDepths(a:Object, b:Object) {
                                                                      var d1:Number = a.depth;
                                                                      var d2:Number = b.depth;
                                                                      if (d1 > d2) {
                                                                      return 1;
                                                                      } else if (d1 < d2) {
                                                                      return -1;
                                                                      } else {
                                                                      return 0;
                                                                      }
                                                                      }

                                                                      hit_mcs.sort(compareDepths);

                                                                      then hit_mcs[0].mc would be a ref to the top mc...


                                                                      • 32. Re: Hittest and overlapping
                                                                        Level 7

                                                                        "_eidolon" <webforumsuser@macromedia.com> wrote in message
                                                                        news:efk3fu$r9b$1@forums.macromedia.com...
                                                                        > Hi
                                                                        >
                                                                        > Im making a lemmings type game for flash
                                                                        > Sometimes there are 2 or more MC's that are over lapping at a certain
                                                                        > point,
                                                                        > all of which are in a hitTest array example code attached. When the
                                                                        > hittest is
                                                                        > run i want to pass a variable to ONLY the top MC, any thoughts on how
                                                                        > todo
                                                                        > this?
                                                                        >
                                                                        > Justin
                                                                        >
                                                                        > for (var i in charArray) {
                                                                        > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                                                                        > _root[charArray
                                                                        ].currentAction = selectedAction;
                                                                        > }
                                                                        >

                                                                        Just an idea... but you could try something like:

                                                                        I assume charArray is an Array of MovieClip refs?

                                                                        NOTE ---- NOT TESTED

                                                                        var hit_mcs:Array = new Array();

                                                                        for (var i:Number = 0; i < charArray.length; i++) {
                                                                        if (charArray .hitTest(_xmouse, _ymouse, true)) {
                                                                        hit_mcs.push({mc:charArray
                                                                        , depth:charArray .getDepth()});
                                                                        }
                                                                        }

                                                                        function compareDepths(a:Object, b:Object) {
                                                                        var d1:Number = a.depth;
                                                                        var d2:Number = b.depth;
                                                                        if (d1 > d2) {
                                                                        return 1;
                                                                        } else if (d1 < d2) {
                                                                        return -1;
                                                                        } else {
                                                                        return 0;
                                                                        }
                                                                        }

                                                                        hit_mcs.sort(compareDepths);

                                                                        then hit_mcs[0].mc would be a ref to the top mc...


                                                                        • 33. Re: Hittest and overlapping
                                                                          Level 7

                                                                          "_eidolon" <webforumsuser@macromedia.com> wrote in message
                                                                          news:efk3fu$r9b$1@forums.macromedia.com...
                                                                          > Hi
                                                                          >
                                                                          > Im making a lemmings type game for flash
                                                                          > Sometimes there are 2 or more MC's that are over lapping at a certain
                                                                          > point,
                                                                          > all of which are in a hitTest array example code attached. When the
                                                                          > hittest is
                                                                          > run i want to pass a variable to ONLY the top MC, any thoughts on how
                                                                          > todo
                                                                          > this?
                                                                          >
                                                                          > Justin
                                                                          >
                                                                          > for (var i in charArray) {
                                                                          > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                                                                          > _root[charArray
                                                                          ].currentAction = selectedAction;
                                                                          > }
                                                                          >

                                                                          Just an idea... but you could try something like:

                                                                          I assume charArray is an Array of MovieClip refs?

                                                                          NOTE ---- NOT TESTED

                                                                          var hit_mcs:Array = new Array();

                                                                          for (var i:Number = 0; i < charArray.length; i++) {
                                                                          if (charArray .hitTest(_xmouse, _ymouse, true)) {
                                                                          hit_mcs.push({mc:charArray
                                                                          , depth:charArray .getDepth()});
                                                                          }
                                                                          }

                                                                          function compareDepths(a:Object, b:Object) {
                                                                          var d1:Number = a.depth;
                                                                          var d2:Number = b.depth;
                                                                          if (d1 > d2) {
                                                                          return 1;
                                                                          } else if (d1 < d2) {
                                                                          return -1;
                                                                          } else {
                                                                          return 0;
                                                                          }
                                                                          }

                                                                          hit_mcs.sort(compareDepths);

                                                                          then hit_mcs[0].mc would be a ref to the top mc...


                                                                          • 34. Re: Hittest and overlapping
                                                                            Level 7

                                                                            "_eidolon" <webforumsuser@macromedia.com> wrote in message
                                                                            news:efk3fu$r9b$1@forums.macromedia.com...
                                                                            > Hi
                                                                            >
                                                                            > Im making a lemmings type game for flash
                                                                            > Sometimes there are 2 or more MC's that are over lapping at a certain
                                                                            > point,
                                                                            > all of which are in a hitTest array example code attached. When the
                                                                            > hittest is
                                                                            > run i want to pass a variable to ONLY the top MC, any thoughts on how
                                                                            > todo
                                                                            > this?
                                                                            >
                                                                            > Justin
                                                                            >
                                                                            > for (var i in charArray) {
                                                                            > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                                                                            > _root[charArray
                                                                            ].currentAction = selectedAction;
                                                                            > }
                                                                            >

                                                                            Just an idea... but you could try something like:

                                                                            I assume charArray is an Array of MovieClip refs?

                                                                            NOTE ---- NOT TESTED

                                                                            var hit_mcs:Array = new Array();

                                                                            for (var i:Number = 0; i < charArray.length; i++) {
                                                                            if (charArray .hitTest(_xmouse, _ymouse, true)) {
                                                                            hit_mcs.push({mc:charArray
                                                                            , depth:charArray .getDepth()});
                                                                            }
                                                                            }

                                                                            function compareDepths(a:Object, b:Object) {
                                                                            var d1:Number = a.depth;
                                                                            var d2:Number = b.depth;
                                                                            if (d1 > d2) {
                                                                            return 1;
                                                                            } else if (d1 < d2) {
                                                                            return -1;
                                                                            } else {
                                                                            return 0;
                                                                            }
                                                                            }

                                                                            hit_mcs.sort(compareDepths);

                                                                            then hit_mcs[0].mc would be a ref to the top mc...


                                                                            • 35. Re: Hittest and overlapping
                                                                              Level 7

                                                                              "_eidolon" <webforumsuser@macromedia.com> wrote in message
                                                                              news:efk3fu$r9b$1@forums.macromedia.com...
                                                                              > Hi
                                                                              >
                                                                              > Im making a lemmings type game for flash
                                                                              > Sometimes there are 2 or more MC's that are over lapping at a certain
                                                                              > point,
                                                                              > all of which are in a hitTest array example code attached. When the
                                                                              > hittest is
                                                                              > run i want to pass a variable to ONLY the top MC, any thoughts on how
                                                                              > todo
                                                                              > this?
                                                                              >
                                                                              > Justin
                                                                              >
                                                                              > for (var i in charArray) {
                                                                              > if (_root[charArray ].hitTest(_xmouse, _ymouse, true)) {
                                                                              > _root[charArray
                                                                              ].currentAction = selectedAction;
                                                                              > }
                                                                              >

                                                                              Just an idea... but you could try something like:

                                                                              I assume charArray is an Array of MovieClip refs?

                                                                              NOTE ---- NOT TESTED

                                                                              var hit_mcs:Array = new Array();

                                                                              for (var i:Number = 0; i < charArray.length; i++) {
                                                                              if (charArray .hitTest(_xmouse, _ymouse, true)) {
                                                                              hit_mcs.push({mc:charArray
                                                                              , depth:charArray .getDepth()});
                                                                              }
                                                                              }

                                                                              function compareDepths(a:Object, b:Object) {
                                                                              var d1:Number = a.depth;
                                                                              var d2:Number = b.depth;
                                                                              if (d1 > d2) {
                                                                              return 1;
                                                                              } else if (d1 < d2) {
                                                                              return -1;
                                                                              } else {
                                                                              return 0;
                                                                              }
                                                                              }

                                                                              hit_mcs.sort(compareDepths);

                                                                              then hit_mcs[0].mc would be a ref to the top mc...