4 Replies Latest reply on Nov 19, 2008 9:52 PM by Rothrock

    onEnterFrame not working

    Happy Camper
      I use onEnterFrame all the time and it works wonderfully. Now on this tiny little job I am spending hours trying to get it to work to no avail.... Very simple file, I am in Flash CS3 Pro.

      There is a movieClip on the root named "mh1". Inside that movieClip is a movieClip named "imageLoader_mc" that 6 JPEGs load dynamically into, animate in and out and then the next one loads up. It works great except online there is a stutter, it begins the animation before the JPEG is loaded... simple enough... but not working, here is my code (which includes my commented out attempt with a listener as well on the bottom)...

      The "num" trace comes back everytime, but it never goes inside of the onEnterFrame... I never see those traces, I tried putting the onEnterFrame code before and after the "loadMovie" command and it doesn't work in either position... any ideas? Any help is extremely appreciated.
        • 1. Re: onEnterFrame not working
          Rothrock Level 5
          I'm surprised that any of this is working. It seems you have mashed together the MovieClipLoader (which you should use) with loadMovie (which unless you need to publish to Flash 5, you shouldn't use).

          The reason you onEnterFrame is not working is that it is attached to the same clip that you are loading into. When you load content into a clip many of the things attached to it are reset. So once you start loading the onEnterFrame handler is removed.

          But that isn't really how you should be handling this anyway. You should use the MovieClipLoader class which is what the last part of your code seems to suggest. First uncomment it. Then to the iListen object add a function for:

          // look up the implementation in the help files

          Then you will also need to create an instance of the MovieClipLoader on the line above your :

          var myMCL:MovieClipLoader=new MovieClipLoader();

          Register the listener to the MCL instance:


          And finally load the clip using the MCL.load() method.

          myMCL.load(("images/masthead" + _root.theNum + ".jpg",imageLoader_mc);
          • 2. Re: onEnterFrame not working
            Happy Camper Level 1
            I am trying to follow this new method... yes it has been my way to make everything Flash5 because it has total penetration on browsers, and I have been working in Flash since Flash4... there is a new form of AS every two years lately, haven't decided which I should be learning.... so please do not insult if it's not right, but I appreciate the help....

            Here is the code using that advice, but I get the same results, no trace coming back on the onLoad functions...


            if(_root.theNum < 6){
            _root.theNum = 1;

            trace("theNum is " + _root.theNum);

            var loader:MovieClipLoader = new MovieClipLoader();

            function onLoadInit(_root.mh1.imageLoader_mc:MovieClip) {
            trace("onLoadInit activated");

            loader.loadClip("images/masthead" + _root.theNum + ".jpg", _root.mh1.imageLoader_mc);
            • 3. Re: onEnterFrame not working
              Rothrock Level 5
              Well you should get errors when you try an publish that. You can't put an actual movieclip in the arguments for the onLoadInit. You want to put a variable name that will get a reference to the clip you loaded into. Also it is considered better practice to attach the call back handlers to an object. And while "this" is a perfectly good object you should do that.

              So I think what this code should look like is:

              var loadListener:Object=new Object();
              var loader:MovieClipLoader = new MovieClipLoader();

              loadListener.onLoadInit=function(target:MovieClip) {
              trace("onLoadInit activated");

              loader.loadClip("images/masthead" + _root.theNum + ".jpg", _root.mh1.imageLoader_mc);
              • 4. Re: onEnterFrame not working
                Rothrock Level 5
                None of this will work in Flash 5. You will need to publish for Flash 7 if you want to use the MovieClipLoader.