1 Reply Latest reply on Jun 1, 2006 7:38 PM by TimSymons

    Dispatching an event from a MovieClip???

      Hello, can somebody tell me if there is a way to dispatch an event from a Movieclip?, I tried to dispatch an event from a class and all ran ok. But now, if I have a Movieclip on my scenario and I want that when it arrive to "x" frame it dispatch an event that could be catched by a listener on the _root, what I have to do? (without doing use of classes), thanks a lot.
        • 1. Re: Dispatching an event from a MovieClip???
          TimSymons Level 1
          Try the following. On the first frame of the movieclip place the following code.

          // Event Routines //
          var dispatchEvent:Function;
          var addEventListener:Function;
          var removeEventListener:Function;

          Then on the "x" frame of the movieclip, place the following code:

          var evt:Object = new Object();
          evt.type = "framereached"; // this can be whatever you wish to listen for
          evt.target = this;

          This is how you would do this in a class and it should work just as well if coded directly onto a frame. However, to make this more versatile I would place it in a class with a public function, for example, name throwEvent(). This public method would then execute the above code and could be called from any frame. You could even add another item to the evt object that would contain the frame the executed the event.