3 Replies Latest reply on Nov 17, 2011 1:20 PM by Adam-C

    Long Delay when switching Flash cast members

    ChuckMoose

      I have a movie that uses Flash cast members as sprites. The Flash members are static images and are optimized as best they can be, but they are using Background transpaerent ink and cannot be direct to stage so I know they use a lot rescources. These sprites are rotated randomly, and that is why I must use Flash members since bitmaps look terrible when they are rotated.  The user can select to change the sprite's members to display different images.  I do this by changing the memberNum property of each sprite.   When that happens on some systems there is a delay of up to 2 seconds while the new Flash cast members are substituted.  All Flash members are internal and are set to Preload before Frame 1.

       

      Can anyone think of what may be causing this delay?

        • 1. Re: Long Delay when switching Flash cast members
          Adam-C Level 2

          Firstly, I'd suggest that rather than rotating the Flash sprite it may be simpler to rotate the contents of the Flash using Flash functions built into the SWF... I'm pretty sure it would be more efficient in terms of processing. If necessary you could wrap your SWF's content into a MoveClip within the main SWF, and then spin the MovieClip using Actionscript in the SWF (if you see what I mean).

           

          As for the delay problem - have you tried using the sprite.member property rather than sprite.memberNum? For example:

           

          on changeMember me, aMemberName

               sprite(me.spriteNum).member = aMemberName

          end

           

          I don't know if this would side-step the problem because I've never come across it before, but it's a thought. Bare in mind that memberNum can be ambiguous because it doesn't specify which cast the member is stored in.

           

          Telling members to preload before frame 1 doesn't guarantee that they will be preloaded - you need to be sure that you've allocated enough preLoadRam. The following would allocate 1MB (1024 KB) of RAM for preloading

           

          on startMovie

               the preLoadRAM = 1024

          end

           

          If your SWFs are large then you may need to up the preLoadRAM value (assuming you can be sure that your users' systems will have enough free RAM).

           

          Finally, you can use the member.preload property to tell Director whether a SWF must load completely before it plays...:

          member("myMember").preload = true

           

          ... or whether the SWF can be streamed from disk as it plays...:

          member("myMember").preload = false

           

          I hope some of this helps.

          1 person found this helpful
          • 2. Re: Long Delay when switching Flash cast members
            ChuckMoose Level 1

            Adam, thank you very much for the advice!

            • 3. Re: Long Delay when switching Flash cast members
              Adam-C Level 2

              Oops - just spotted a mistake in my own answer...:

               

               

              on changeMember me, aMemberName

                   sprite(me.spriteNum).member = aMemberName

              end

              Should be

               

              sprite(me.spriteNum).member = member(aMemberName)