2 Replies Latest reply on Nov 26, 2011 8:30 PM by werzaque

    currentFrame and totalFrames not working as intended

    werzaque Level 1

      Hi,

       

      I have a peculiar problem with a swf published from Captivate (full motion recording, single slide). I wish to use the swf in another flash movie, and basically want to have things triggered when the movie has finished playing (like going to the next frame, where I plan to embed another swf). After doing some research, I decided to go with a method in which the movie's current frame is compared with the movie's total number of frames. To my surprise, the trigger occurs after only one second. Tracing the MovieClip(myLoader.content).currentFrame and MovieClip(myLoader.content).totalFrames reveals that the first one stops at 32, and the second one returns also 32 (according to captivate, it has 1411 frames). Yet the movie keeps playing.

       

      I'm guessing that I'm referencing the wrong "currentFrame" and "totalFrames", but am completely lost as to why it's not working like it should.

       

      var myLoader:Loader = new Loader();

      var url:URLRequest = new URLRequest("DEF_adding_parameter.swf");

      myLoader.load(url);

      myLoader.contentLoaderInfo.addEventListener(Event.COMPLETE,loadComplete);

       

      function loadComplete(e:Event)

      {

                stage.addEventListener(Event.ENTER_FRAME, endOfMovie);

      }

       

      addChild(myLoader);

       

      function endOfMovie(e:Event)

      {

                trace(MovieClip(myLoader.content).currentFrame);

                trace(MovieClip(myLoader.content).totalFrames);

                if (MovieClip(myLoader.content).currentFrame==MovieClip(myLoader.content).totalFrames)

                {

                          MovieClip(myLoader.content).stop();

                          stage.removeEventListener(Event.ENTER_FRAME, endOfMovie);

                          stage.addEventListener(Event.ENTER_FRAME, go_nextFrame);

                }

      }

       

      Thanks in advance!

        • 1. Re: currentFrame and totalFrames not working as intended
          Ned Murphy Adobe Community Professional & MVP

          Chances are if the currentFrame ends at 32 and the totalFrames returns 32, it is working like it should, just not as you desire.  I have no idea what goes on with Captivate, so you might want to inquire in the  forums for that product regarding the structure of your Captivate-generated file...

           

          http://forums.adobe.com/community/adobe_captivate/adobe_captivate_general?view=discussions

           

          One thing you might be able to do with your endOFMovie function to investigate is to check the numChildren property of the loaded file, and trace each one ( trace(getChildAt...) ) to see which ones are movieclips, and then trace the totalFrames property of the movieclips that you find.  That might lead you to finding the animation sequence you are interested in.

          1 person found this helpful
          • 2. Re: currentFrame and totalFrames not working as intended
            werzaque Level 1

            Thanks for the advice! After doing some research on it, I found out that the correct way to obtain the current and total frames of captivate-generated swfs is to use:

             

            MovieClip(myLoader.content).rdinfoCurrentFrame

             

            and

             

            MovieClip(myLoader.content).rdinfoFrameCount

             

            It kind of works now... but now I'm getting the following message in the output at every single frame after the Loader loads another swf:

             

            TypeError: Error #1009: Cannot access a property or method of a null object reference.

                      at captivate.veela_as3::rdSwfLoader/IsParentSlidelet()

                      at captivate.veela_as3::rdItem/getParentCurrFrame()

                      at captivate.veela_as3::rdSwfLoader/getParentCurrFrame()

                      at captivate.veela_as3::rdSwfLoader/rdSwfLoaderEnterFrame()

             

            Curious thing is that it doesn't happen everytime. The load of swfs can also be triggered by button clicks, and when I go back and forth between swfs the error doesn't show up at all. I'll try asking the captivate forum.