7 Replies Latest reply on Dec 15, 2006 8:29 AM by Newsgroup_User

    Advice on Load / Unload Flash Member

    andyulrika_is_back
      Hello

      I have an animated flash member which is fairly large and contains animation and audio. I want to be able to preload the flash member on entering the frame and unload the flash member on exiting the frame.

      Below is what I have so far - Could someone please tell me if this is the best way to proceed!

      property pFlashanimation

      on getPropertyDescriptionList me
      list = [:]
      addProp list, #pFlashanimation, [#comment: "FlashMovie:",\
      #format: #flash, #default: "AnimationName?"]
      return list
      end

      on beginSprite me
      sprite(me.spriteNum).member=pFlashanimation
      preLoad((pFlashanimation))
      end

      on endSprite me
      sprite(me.spriteNum).member=pFlashanimation
      unLoad((pFlashanimation))
      end


      Any help much appreciated.

      regards

      Andy
        • 1. Re: Advice on Load / Unload Flash Member
          Level 7
          Hi Andy,

          If you are working on Windows then you can open the Memory inspector
          window to see how much memory is used as your movie plays. If, without
          your behavior, you don't see any change in the amount of memory used
          when you get to the Flash sprite in the score, you can assume that the
          member is already loaded in to memory.

          When Director begins it goes through the entire score and loads in every
          cast member reference until it either runs out of memory or it runs out
          of members to load. If your Flash member is instanced as a sprite in the
          score then it will probably be loaded in to memory.

          In the past, when computers had much less memory and processors were
          slower, it was very important to preload some of the movie in to memory
          and then control memory use as the show progressed. Now with 512 meg or
          1 gig of ram as the norm, this procedure is less critical.

          There is still the problem of video memory and the pre-rendering of the
          stage. This is usually only an issue with laptops anymore. You can still
          see a delay in screen painting on computers where the screen resolution
          is large but the available video ram is less than adequate.

          In any case, by the time the playback head has hit your flash sprite,
          its too late to preload the member. That step has already taken place.

          If you need to preload this member, a better tactic is to place the
          preloading code someplace before you need to use that member. If the
          frame playback is predictable up to the introduction of this sprite,
          then you could put a preload command a few frames before you need this
          member.

          You might want to issue an unload() command at some point before you
          issues the preload. This will get memory space freed up before you begin
          to load in something new.

          Loading and unloading members takes some processor attention away from
          playing your movie. Try to use these commands at some point where your
          playback head is sitting static on a frame so that you don't slow down
          playback.

          --
          Rob
          _______
          Rob Dillon
          Adobe Community Expert
          http://www.ddg-designs.com
          412-243-9119

          http://www.macromedia.com/software/trial/
          • 2. Re: Advice on Load / Unload Flash Member
            andyulrika_is_back Level 1
            Hi Rob

            Thank you for the information, it was interesting reading. I'm going to take your advice and try some preloading a few frames before the flash member is present. Incidentally, I use my laptop to work on and I wondered if I was suffering because of that! More of a convenience for me anyway.

            At present, I haven't noticed any memory drop in the memory inspector when I exit a frame (using the code below). However, I shall need to do more testing - especially when I burn to CD-ROM. However, I have been looking into streaming. Correct me if I'm wrong but is that not just used for Shockwave web content. Or, does it bare any relevancy when reading from CD-ROM?

            regards

            Andy
            • 3. Re: Advice on Load / Unload Flash Member
              Level 7
              Hi Andy,

              No, streaming is only useful for playing a file that has only partially
              downloaded from a server. When the file is local, on a CD or hard drive,
              the whole file is available and will play immediately.

              --
              Rob
              _______
              Rob Dillon
              Adobe Community Expert
              http://www.ddg-designs.com
              412-243-9119

              http://www.macromedia.com/software/trial/
              • 4. Re: Advice on Load / Unload Flash Member
                andyulrika_is_back Level 1
                Cheers Rob. You learn something every day - eh!

                regards

                Andy

                • 5. Re: Advice on Load / Unload Flash Member
                  Level 7
                  On Sun, 10 Dec 2006 21:27:31 GMT, andyulrika_is_back posted in
                  macromedia.director.lingo:

                  > At present, I haven't noticed any memory drop in the memory inspector
                  > when I exit a frame (using the code below).

                  FYI, and I don't recall if it's fixed in MX2004, but Dir for Windows has a
                  bad history of reporting innacurate results for free RAM using the Lingo
                  commands. Not sure if it also applies to the Memory Inspector, but I learned
                  not to trust Dir's results. (Its memory management is still outstanding, it
                  just didn't report accurate figures for RAM)

                  If Lingo's freeBytes and freeBlock return impossible results (freeBytes =
                  ~2MB more RAM than you have installed and/or freeBlock = the actual amout of
                  RAM you have installed), then I recommend using the Task Manager, Buddy API,
                  or any other memory monitor you have.

                  Also, I see your endSprite event is loading the flash member again.

                  > on endSprite me
                  > sprite(me.spriteNum).member=pFlashanimation
                  > unLoad((pFlashanimation))
                  > end

                  Shouldn't that be setting sprite(me.spriteNum).member back to its original
                  member or to a 'place holder' member?


                  --
                  Mark A. Boyd
                  Keep-On-Learnin' :)
                  • 6. Re: Advice on Load / Unload Flash Member
                    andyulrika_is_back Level 1
                    Hi Mark

                    Thanks for the comments, although I don't understand how I am preloading again...can you explain?

                    thanks

                    Andy



                    • 7. Re: Advice on Load / Unload Flash Member
                      Level 7
                      On Fri, 15 Dec 2006 13:16:48 GMT, andyulrika_is_back posted in
                      macromedia.director.lingo:

                      > Thanks for the comments, although I don't understand how I am preloading
                      > again...can you explain?

                      Preloading? I might be inclined to call it postloading if I had to put a
                      prefix on it ;)

                      A snippet from the code you posted earlier:

                      > on endSprite me
                      > sprite(me.spriteNum).member=pFlashanimation
                      > unLoad((pFlashanimation))
                      > end

                      The second line, sprite(me.spriteNum).member=pFlashanimation, is telling the
                      sprite to refer to the cast member reference stored in pFlashanimation - just
                      as you intended for the beginSprite event.

                      And, of course, it is already in memory since you loaded it in beginSprite
                      (or earlier if you've acted on Rob's advice by now).

                      I don't think any harm is done as I suspect that Director receives that
                      command, determines that member(pFlashanimation).loaded is already true and
                      ignores the command.

                      I just don't see any use for that line in the endSprite event since the very
                      next line is supposed to unload that member.

                      HTH

                      --
                      Mark A. Boyd
                      Keep-On-Learnin' :)