10 Replies Latest reply on Jul 9, 2008 12:27 PM by Production Monkey

    Pre-loading entire project into memory before playing?

    Navarro Parker Level 3
      How can I preload an entire project into memory before it starts playing? All my projects play locally off the HD. Using preLoadMember and preloadMovie doesn't do the trick. I've seen kiosk projects that use preloaders and they dramatically improve the smoothness of animation.

      I have seen projects that have a preloader progress bar showing how the load progresses. I'd really like to show the status of my preload too.

        • 1. Re: Pre-loading entire project into memory before playing?
          UdoGre Level 1
          Hi Navarro,
          You usually don't need preload when playing from HD. What assets are slow? Videos? You can try to put them in the score a few frames before you need them, positioned offstage (and paused, of course). If it's something else, you either have a veery slow computer/HD, or you can improve your animations somehow. Could you then give some example of a slow animation?

          A progress bar for a local preload can only be faked, AFAIK.

          HTH,

          Udo
          • 2. Re: Pre-loading entire project into memory before playing?
            Navarro Parker Level 3
            I've seen a couple Director projects that have a preloader and it plays back perfectly smooth once loaded. If I skip the preloader, it "chugs" and there's choppy playback. Unfortunately, these are projector files, so I can reverse engineer whatever magic preloader script they are using.

            All image sequences are slow (Final Cut video and After Effects animation rendered out as a series of still images).

            I can't post anything because everything is under NDA, unfortunately.
            • 3. Re: Pre-loading entire project into memory before playing?
              rafa@mediatech Level 1
              Hi Navarro:
              So you rendered your videos still images, and then added each image one next to the other so that it plays as if animated, correct?
              If so, the reason it plays slow it because it is loading one image at a time. I rendered something once in after effects that I needed to use as a animated background. It was a series of images (about 100) which created a loop animation (it looked awesome!).

              But if I didn't pre-load them before I used them it looked like crap. What I did was, I loaded each one at the beginning using the "preload member" command on the script frame. Something like this:

              on exitFrame me
              preloadmember("Comp 1_00000")
              end

              And I did that about 100 times. It took forever, but the animation looked a lot smoother once it played. I created a square shape in the first frame, and key framed it as extended in the last "preloadmember" script. This created the fake load bar UdoGre mentioned. Not really fake, since the members where being loaded i guess.
              Anyway, I haven't used this technique again because it takes way too much time, but let me know if this is what you where looking for.

              Rafael.
              • 4. Re: Pre-loading entire project into memory before playing?
                Production Monkey Level 3
                " I loaded each one at the beginning using the "preload member" command on the script frame. Something like this:

                on exitFrame me
                preloadmember("Comp 1_00000")
                end"

                No.. Wrong. ExitFrame should only be used for code that needs to be executed over and over again, like an animation. You only need to load your graphics once. Use startMovie or prepareMovie.

                on startMovie
                _movie.preLoadMember(fromMemNameOrNum, toMemNameOrNum)
                end

                You may want to calculate your memory usage and compare that to your minimum system requirements. If the system runs out of RAM it will page it to hard disc and you will make the user wait while the computer copies the files from one place on the hard drive to another.

                Do have some reason for not using video? What size (width x height) are your images? Do you play multiple at once?
                • 5. Re: Pre-loading entire project into memory before playing?
                  Navarro Parker Level 3
                  Thank Rafael.

                  I see that you used typed preloadmember("Comp 1_00000"). Does this exact script go on every frame or on the next frame say frame 2 it says preloadmember("Comp 1_00002")? Also how do you tell it to go to a specific cast if you have more than one cast?

                  Also, I'm using Cast To Time for all my image sequences.

                  Do you happen to have this old profile file I could take a look at?
                  • 6. Re: Pre-loading entire project into memory before playing?
                    rafa@mediatech Level 1
                    Is there a way to use "on StartMovie" and still fake the load bar effect?

                    Rafael.
                    • 7. Re: Pre-loading entire project into memory before playing?
                      rafa@mediatech Level 1
                      Yes Navarro, I can send you the file I used, it isn't anything confidential. But I would suggest trying what Production Monkey suggested, it might work better, like I said, I haven't used the technique again because it takes waaaaay too much time. Send me an email, and I will forward the file to you, my email is
                      rafaelATmediatechplusDOTcom (replace At and DOT...)

                      Rafael.
                      • 8. Re: Pre-loading entire project into memory before   playing?
                        Level 7
                        Yeah. You can have your loading code in startMovie and still have a
                        progress meter. In frame 1, put your progress meter sprite(s) and in
                        the startMovie script set the progress meter as it needs to be, then do
                        an updateStage() so the sprites respond. Then do the next preload...
                        repeat as needed...

                        I have done that before and it worked out pretty well. As long as you
                        don't have anything complex in frame 1... it should be just the progress
                        meter and maybe some background graphics. No Flash, video, or other such
                        intensive sprites until at least frame 2.
                        • 9. Re: Pre-loading entire project into memory before playing?
                          Navarro Parker Level 3
                          HI Monkey! Thanks for your reply.

                          Minimum system requirements are not an issue. They only play on beefy systems (3GHz Core 2 Duo + 4 GB RAM + 512MB graphics card). I'm not trying to deliver a compact project -- these usually run 300MB~1GB.

                          Image Sequences (PNG, JPEG, GIF) have proven to be more reliable. They don't reference external files, so there is only one file to deliver to clients. Also, looping Quicktime movies quickly get out of sync with other events. Plus, placing cast members on top of Quicktime movies reduces playback speed even more. The video we're playing can range from 1024x768 all the way up to 1920x1080 (which I realize is massive).
                          • 10. Re: Pre-loading entire project into memory before playing?
                            Production Monkey Level 3
                            Those are some large images. That explains your playback problem. Under your memory conditions I would preload the images as well.

                            Creating a progress bar is easy enough. Write a behavior for your progress bar with a method called "setBarLength(percentage)" that updates the image of the sprite to reflect the percentage passed in. Attach that to an image sprite on frame one, sprite one.

                            The basic approach to updating the progress bar would be something like below. You may want to write something a bit more flexible using a repeat loop and the mod function for graphic updates.

                            on startMovie
                            ProgressBar = Sprite(1)

                            _movie.preLoadMember(1, 200)
                            ProgressBar.setBarLength(10)
                            updateStage()

                            _movie.preLoadMember(201, 400)
                            ProgressBar.setBarLength(20)
                            updateStage()

                            _movie.preLoadMember(401, 600)
                            ProgressBar.setBarLength(30)
                            updateStage()

                            _movie.preLoadMember(601, 800)
                            ProgressBar.setBarLength(40)
                            updateStage()

                            --- etc.
                            end startMovie