4 Replies Latest reply on Jul 6, 2007 4:49 AM by cicnats

    listener onEnterFrame ?

    chrisatflash Level 1
      Hello,
      I am trying to make a listener to an OnEnterFrame event.
      But it does not work.

      Does anyone know what i am doing wrong?

      Regards,

        • 1. Re: listener onEnterFrame ?
          Level 7

          Hi Micheal,

          the enterFrame event is an event belonging to a timeline/movieclip. The
          onEnterFrame eventhandler therefore should be attached to a timeLine object.

          In AS2 that would be a movieClip object. Those do not support the
          addListener method (see helpfiles) so it would be:

          movieClipInstance_mc.onEnterFrame = function () {
          trace ("some text ");
          }

          In AS3 I'm still a bit shaky, but this would work:


          function my_onEnterFrame(event:Event){
          trace("frameupdate in: " + event.target.name);
          }

          movieClipInstance_mc.addEventListener(Event.ENTER_FRAME, my_onEnterFrame);

          First declare a function and then add an eventListener to the movieClip
          instance.

          HTH,
          Manno


          Michealnl wrote:
          > Hello,
          > I am trying to make a listener to an OnEnterFrame event.
          > But it does not work.
          >
          > Does anyone know what i am doing wrong?
          >
          > Regards,
          >
          >
          >
          > var listen:Object = new Object();
          >
          > listen.onEnterFrame = function () {
          > trace ("some text ");
          > }
          >
          >
          > onEnterFrame.addListener(listen);
          >

          --
          ----------
          Manno Bult
          http://www.aloft.nl
          • 2. listener onEnterFrame ?
            cicnats
            err.. what?? you don't need a listener for an onEnterFrame event ;)

            you assign it either to the current timeline with
            onEnterFrame = function() {...
            or
            this.onEnterFrame = function() {...

            or to a specified movie clip from code outside the movieclip:
            mc_name.onEnterFrame = function() {...

            or directly to a movieclip that you select on stage and open the actions panel
            onClipEvent(enterFrame) {...

            but you don't need a listener for that.. what are you trying to make?

            but if you did want to set a listener for something else, it wouldn't work like in your code:

            onSomeEvent.addListener(listener_object);

            but

            object_that_requires_some_listener.addListener(listener_object);

            in other words, you attach a listener object to an object that requires listeners for certain events, not to the events themselves.

            try looking at the reference for MovieClipLoader, for example, to get a clearer idea:
            http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveD ocs_Parts&file=00002539.html


            • 3. Re: listener onEnterFrame ?
              chrisatflash Level 1
              Thanks!
              I did not know that object on the timeline are connected to the onEnterFrame event.

              To cicnats : The reson why i do this, because i want to delete an onEnterFrame function.
              But when i do delete this onEnterFrame is delete all the onEnteFrame functions.



              • 4. Re: listener onEnterFrame ?
                cicnats Level 1
                ok, I don't know as3, so I can't help there..

                quote:

                The reson why i do this, because i want to delete an onEnterFrame function.
                But when i do delete this onEnterFrame is delete all the onEnteFrame functions.


                uh.. that shouldn't happen.. every movieclip and the timeline have their own onEnterFrame event handling function.. deleting one function shouldn't delete the others..