7 Replies Latest reply on Feb 21, 2007 8:19 PM by Denise Hambrick

    displying the duration of loaded .swf files

      I've created an online Flash presentation that works by loading numerous .swf files into a container. It can be viewed here:

      As each .swf plays, another is automatically loaded. Since the duration runs about 30 minutes I want to show the viewer how far into the presentation they are at any given time, simiar to a progress indicator when watching a video. I've created a progress bar that resides in the container file and it kind of works, but it's not built correctly. I had to fake it (no need to go into detail) to make seem like it's monitoring the duation. Is there a way to create something that shows tells the whole length of the presentation and then count's down? For instance having a little box that starts off at 30:00 minutes and counts down as the presentation plays until it hits 00:00 and it's over. I'm just not sure where to start in setting something like this up, espcially since the entire presentation consists of mulitple .swfs.
        • 1. Re: displying the duration of loaded .swf files
          injpix Level 3
          How are these SWFs being played? Are they movies that are played from the timeline? Are they loading a FLV into them? How is this “time” being clocked? Depending on your answer will determine what code will be needed.
          • 2. Re: displying the duration of loaded .swf files
            Level 7
            If all the SWF's are loaded, you can look at the _totalFrames property of
            each to calculate the number of frames. AS you know the framerate, you can
            easily calculate the times from that (this is assumign the SWF's don't loop
            and just play from start to end)

            • 3. Re: displying the duration of loaded .swf files
              bb73 Level 1
              Yes, they are movies played from the timeline. No .flvs involved. The container file calls on each .swf file to load into a target on the container's timline. Each .swf then plays through one at a time and the next .swf in line gets loaded upon completion. There are keyframes that conaint actionscript that says to load a specific .swf, then load the next one upon completion. The following is the code used to load the first .swf (001.swf, then load the next one in line, with is 004.swf:

              /*Indicates name of SWF to play. Used by loaded and preloaded
              SWFs to prevent premature playback.*/
              SWFPlayIndic = "001.swf";

              /*Calls function Preloader and sets
              1) External SWF to load for playback
              2) External SWF to preload for playback in next frame.*/


              Right now I'm not actually clocking the time. There is are separate movie clips in the container file that are assigned to each .swf that play the progress bar as each swf is loaded. Ilke I said before, I had to fake it. :)
              • 4. Re: displying the duration of loaded .swf files
                injpix Level 3
                Yeah, if you are not using FLVs then do what Jeckyl suggested. The code below will load a SWF and when the onLoadInit event handler is invoked it will retrieve the incoming SWF’s totalframes property. I then divided this value by the FPS (frames-per-second) value (12). I don’t think there is an easy way to find out the SWF’s FPS. Also this code creates an empty movieclip 'container' that loads the incoming SWF.
                • 5. Re: displying the duration of loaded .swf files
                  Denise Hambrick Level 1
                  I have a similar requirement to show current time and total time of separate swfs that each include flvs and some interactions. Is there a way to monitor the time to complete or elapsed time to total time with this situation?

                  If I can do this for one, I'm thinking I can have the start time for the second one begin at the end time of the first one and so on. Each swf (actually exe) file is on a separate CD.

                  Any ideas?
                  • 6. Re: displying the duration of loaded .swf files
                    injpix Level 3
                    Having interactions in a SWF would make it impossible to predict the total time as you probably know. Having key points in the application which will update the amount of time that is left would be ideal. You can monitor the user’s current time by using setInterval( ) and/or getTimer().
                    • 7. Re: displying the duration of loaded .swf files
                      Denise Hambrick Level 1
                      Thanks. I check into that. I may come back with more questions, but this gives me a place to work from.