2 Replies Latest reply on May 24, 2007 3:14 AM by smazr123

    AS3 Click Event being wierd

    smazr123
      Im using a Click event on a linkaged movie clip so that when you click on it, it will run a function defined in root. That all works fine, but it seems to pass a different event target depending on where you click in the movie. If you click on the background it passes the movieclip instance itself, but if you click on a text field in the movieclip it passes that as the event target. The Click event is registered with the movieclip instance, shouldnt that be returned as the target no matter what other movies are in it? whats the deal?

      This is the code on the first frame of the linkaged movie clip:

      this.addEventListener(MouseEvent.CLICK, root.eventClick);
        • 1. Re: AS3 Click Event being wierd
          Level 7
          The target is the object being clicked. The currentTarget is the object
          handling the event.

          In your case currentTarget would be your movie clip because that is what is
          using addEventListener (and handling the event).

          If you want root, for your example you would simply reference 'this' in
          eventClick (assuming it was defined as a named function)


          "smazr123" <webforumsuser@macromedia.com> wrote in message
          news:f31mug$nei$1@forums.macromedia.com...
          > Im using a Click event on a linkaged movie clip so that when you click on
          > it,
          > it will run a function defined in root. That all works fine, but it seems
          > to
          > pass a different event target depending on where you click in the movie.
          > If you
          > click on the background it passes the movieclip instance itself, but if
          > you
          > click on a text field in the movieclip it passes that as the event target.
          > The
          > Click event is registered with the movieclip instance, shouldnt that be
          > returned as the target no matter what other movies are in it? whats the
          > deal?
          >
          > This is the code on the first frame of the linkaged movie clip:
          >
          > this.addEventListener(MouseEvent.CLICK, root.eventClick);
          >


          • 2. Re: AS3 Click Event being wierd
            smazr123 Level 1
            OOhhhhhhhhhhhhh, i see. Thats extremely helpful. Thanks.