11 Replies Latest reply on Aug 31, 2012 12:39 PM by kglad

    Whats the correct way to cacheasbitmap when animating on the timeline

    DKNMSIS

      After i finish the animations I find that every keyframe has the instance field blank so i have to fill in the instance that was named at the beginning of the animation.
      is this normal? when i state that instance to cacheasbitmap is it caching it every new keyframe since it thinks theres a new instance ocurring? or will it cache once and then use that for each keyframe following, the animations include a static image moving around the screen in classic tweens.

       

      also should i be using graphic symbols instead of movieclips? for 100+ things that need to be cached? i hear graphic symbols are much more efficient then movieclips but i dont know anyother way to cacheasbitmap with a graphic symbol, it wont let me assign an instance name.s there any other nuances or details im missing or doing wrong when using this feature? I have an imence amount of vector art that is being cached at the beginning of the level and so far it runs okay but less than perfect. I just want to make the art more efficien

        • 1. Re: Whats the correct way to cacheasbitmap when animating on the timeline
          kglad Adobe Community Professional & MVP

          if you start with an object in a keyframe, assign it an instance name and then add more keyframes in frames greater than that initial keyframe, the same instance name will be maintained.

           

          if you're doing anything else, instance names will be lost and, in fact, even objects that look the same and have the same instance name will be considered different objects by flash.

           

          also, you normally would NOT apply cacheAsBitmap to a movieclip that changes frames because each keyframe (whether the movieclip's bitmap changes or not) will generate another bitmap.

           

          even in apps for mobiles where you can otherewise beneficially apply cacheAsBitmap and cacheAsBitmapMatrix, it may not be benefiicial for movieclips that change frames.

          • 2. Re: Whats the correct way to cacheasbitmap when animating on the timeline
            DKNMSIS Level 1

            what do you mean change frame? as in move? or as in hold a different animation requireing another cache as bitmaps?

             

            The changes my movieclips make are just static pictures moving around and almost all the animation was designed this way so I could cache them as bitmap.

            Some movieclips get transformed and end up using cacheasbitmapmatrix but for the most part they are not animated movieclips just static vector art saved as a movieclip then caches as a bitmap and moved about the screen.

            as far I understand, animation in general is not possible without keyframes so I'm not sure how i would change what i have done so far.

             

            also is there anyway of telling if the instance is considered a different object from the original object? how can i identify which ones fash considers individual objects and not one instance?

             

            Is there a way to trace out text everytime something is cached so i can tell when unnessary caching is going on?

            • 3. Re: Whats the correct way to cacheasbitmap when animating on the timeline
              kglad Adobe Community Professional & MVP

               

               

              what do you mean change frame? as in move?

              yes

              or as in hold a different animation requireing another cache as bitmaps?

              and yes, if you change frames, flash re-caches that movieclip (whether you think it needs to or not)

               

              The changes my movieclips make are just static pictures moving around and almost all the animation was designed this way so I could cache them as bitmap.

              you can and should cache each static picture.  you can use a sprite sheet or create your own array of bitmaps to use on the stage using partial blitting or stage blitting.

               

              Some movieclips get transformed and end up using cacheasbitmapmatrix but for the most part they are not animated movieclips just static vector art saved as a movieclip then caches as a bitmap and moved about the screen.

              as far I understand, animation in general is not possible without keyframes so I'm not sure how i would change what i have done so far.

              again, cacheasbitmap and cacheasbitmapmatrix are not helpful with movieclips that change frames.

               

              also is there anyway of telling if the instance is considered a different object from the original object? how can i identify which ones fash considers individual objects and not one instance?

              you can use actionscript to effect an observeable change in your instance(s) and see what changes.

               

              Is there a way to trace out text everytime something is cached so i can tell when unnessary caching is going on?

              you can trace system memory (system.totalMemory).  that will not tell you want is causing the memory increase if you see memory use increasing.  i don't know any way to know via code what bitmaps are being cached.

              and, all that said, if you're not having a performance problem (and you need to test on your target - not development - platform), you don't need to change anything you're doing.

              • 4. Re: Whats the correct way to cacheasbitmap when animating on the timeline
                DKNMSIS Level 1

                humm, I'm still not understanding a few things, thanks for the quick reply though.

                 

                so what you saying is that for anything that is completley static like a background, those are the only things that should be cached as bitmap...

                 

                but what about an animation where a cached movieclip moves left, thats all it does, it just moves left. your saying i have to make a spritesheet and each sprite moved over to the left in a specified area? or create the sprite in a spritesheet and then manualy move the sprite as a graphic?

                 

                how would cacheasbitmap matrix even work if it is not being transformed in an animation? thats what it was intended for i assume.

                 

                acording to the explination of http://www.republicofcode.com/tutorials/flash/as3cacheasbitmap/

                "You should use cacheAsBitmap only in situation where your vector graphic will remain the same or will have its x or y properties updated."

                 

                thats essentialy what i have followed in my animations, anything that moves around on the screen with classic motion tweens and keyframes uses cache as bitmap

                 

                and anything that is rotated or transformed is using matrix,

                 

                you're saying that i can only use cacheing for static objects, correct?

                 

                This is where I'm confused.

                 

                also what happens when you have a bunch of static X and Y moving graphics that are cached as bitmaps inside a movieclip that is rotating back and fourth..
                does everything inside that rotating movieclip have to be cacheasbitmapmatrix?

                1 person found this helpful
                • 5. Re: Whats the correct way to cacheasbitmap when animating on the timeline
                  kglad Adobe Community Professional & MVP

                   

                   

                  humm, I'm still not understanding a few things, thanks for the quick reply though.

                   

                  so what you saying is that for anything that is completley static like a background, those are the only things that should be cached as bitmap...

                  i didn't say that.  i am trying to make a point about caching a movieclip that changes frames.  any other changes to a movieclip published for adobe air (which i assume you are using) will not hinder performance if you use cacheasbitmap AND cacheasbitmapmatrix.

                   

                  but what about an animation where a cached movieclip moves left, thats all it does, it just moves left. your saying i have to make a spritesheet and each sprite moved over to the left in a specified area? or create the sprite in a spritesheet and then manualy move the sprite as a graphic?

                  if a movieclip only moves left-right/up-down, you don't need to use cacheasbitmapmatrix.  just using cacheasbitmap will improve performance.

                   

                  how would cacheasbitmap matrix even work if it is not being transformed in an animation? thats what it was intended for i assume.

                  if a movieclip is not only translated (right-left/up-down) but also faded, scaled, rotated or skewed (but no frame changes), using both cacheasbitmap and cacheasbitmapmatrix (air only) will improve performance.

                   

                  acording to the explination of http://www.republicofcode.com/tutorials/flash/as3cacheasbitmap/

                  "You should use cacheAsBitmap only in situation where your vector graphic will remain the same or will have its x or y properties updated."

                   

                  thats essentialy what i have followed in my animations, anything that moves around on the screen with classic motion tweens and keyframes uses cache as bitmap

                   

                  and anything that is rotated or transformed is using matrix,

                   

                  you're saying that i can only use cacheing for static objects, correct?

                   

                  This is where I'm confused.

                   

                  you (or me or both of us) are confused about what is changing frames.  if you have a movieclip on the main timeline (tweened or not), the main timeline changes frames.  the main timeline should not be cached.  as long as the movieclip doesn't change its frames, caching that movieclip (with cacheasbitmapmatrix if the movieclip is faded,scaled,rotated or skewed) will improve performance.

                   

                  also what happens when you have a bunch of static X and Y moving graphics that are cached as bitmaps inside a movieclip that is rotating back and fourth..
                  does everything inside that rotating movieclip have to be cacheasbitmapmatrix?

                  if you cacheasbitmap a movieclip that's stationary but it has child objects that are not stationary, that movieclip will be re-cached every time a child changes (ie, each time the parent bitmap changes) harming performance.  if a child changes frequently, you're better off not caching the parent movieclip.

                  1 person found this helpful
                  • 6. Re: Whats the correct way to cacheasbitmap when animating on the timeline
                    DKNMSIS Level 1

                    thanks allot, I think I'm just getting hung up on your defination of changing frames.

                     

                    so the movieclip that needs to be cached should not have any animation on the timeline, it should just be one frame. and the animation should be inside of the movieclip with the parent single-frame movieclip specified as cacheasbitmap?

                    Right now, i have my movieclips moving around and then I'm telling each keyframe instance or instance in general to be cached. that is not the right way to cache movieclips is it?

                     

                    suppose I had a parent animation, in this case lets say a boat or something. and that boat is rocking back and fourth. How would I acomplsh getting the people or animated (cached) objects to ride along with the boat. Thats the current situation I'm in. in this situation i could make the boat stop rotating and just bob up and down so that the childs are not rotated or skewed, would that be the only option at this point? or is there a more efficient way to acomplish this.

                     

                    on a side note, i hear graphic symbols are much more efficient. when people say that, is that just for bitmaps? the only symbol or container that lets me provide an instance name is movieclips, would it make sence to work with graphic symbols somehow and cache them as bitmaps as well or is it not worth the trouble

                     

                    Thanks allot for your help by the way, I really appriciate it.

                     

                    on a side-side note this forum always messes up when I'm typing and sends my curser up and few lines when I'm typing maybe very 2 minutes.. have you seen this before or is it only me. I havent used this site in months but as soon as i came back to it today the same thing keeps happening

                    1 person found this helpful
                    • 7. Re: Whats the correct way to cacheasbitmap when animating on the timeline
                      kglad Adobe Community Professional & MVP

                      DKNMSIS wrote:

                       

                      thanks allot, I think I'm just getting hung up on your defination of changing frames.

                       

                      so the movieclip that needs to be cached should not have any animation on the timeline, it should just be one frame. and the animation should be inside of the movieclip with the parent single-frame movieclip specified as cacheasbitmap?

                      it should not have animation on its timeline and no child movieclip should animate. if a child movieclip animates, the child should be cached (as long as it has no child that animates).

                      Right now, i have my movieclips moving around and then I'm telling each keyframe instance or instance in general to be cached. that is not the right way to cache movieclips is it?

                      i can't tell. it depends on how you set things up.  for example, if you have a movieclip that you add to a main timeline keyframe and then cache it, it need not be cached again when you add more keyframes to the main timeline .

                       

                      but if you set it up any other way, you will have different instances on each keyframe and you will need to cache them all (using a lot more memory).

                       

                      suppose I had a parent animation, in this case lets say a boat or something. and that boat is rocking back and fourth. How would I acomplsh getting the people or animated (cached) objects to ride along with the boat. Thats the current situation I'm in. in this situation i could make the boat stop rotating and just bob up and down so that the childs are not rotated or skewed, would that be the only option at this point? or is there a more efficient way to acomplish this.

                      the deepest child should be cached, not any parent unless the parent has descendents that do not move and do not change in any way.  in that situation you only need to cache the parent, none of the descendent children.

                       

                      on a side note, i hear graphic symbols are much more efficient. when people say that, is that just for bitmaps? the only symbol or container that lets me provide an instance name is movieclips, would it make sence to work with graphic symbols somehow and cache them as bitmaps as well or is it not worth the trouble

                      there's no reason to use graphic symbols ever in flash unless you need to see the symbols animation while scrubbing the main timeline in the authoring environment.

                      graphic symbols hinder performance more than movieclips (by about 10%) even without caching the movieclips.  with movieclip caching, movieclips are far more performance friendly.

                       

                      Thanks allot for your help by the way, I really appriciate it.

                      you're welcome.  (p.s. please mark helpful/correct responses)

                       

                      on a side-side note this forum always messes up when I'm typing and sends my curser up and few lines when I'm typing maybe very 2 minutes.. have you seen this before or is it only me. I havent used this site in months but as soon as i came back to it today the same thing keeps happening

                      it's not just you.  i have that problem periodically, too.  i'm not sure it's every 2 minutes, though.

                      • 8. Re: Whats the correct way to cacheasbitmap when animating on the timeline
                        DKNMSIS Level 1

                        thanks for your answers, I've marked them as helpful/correct, one last question before before this drags on too long.

                         

                        "it should not have animation on its timeline and no child movieclip should animate."

                        if the timeline cant have animation on it, and the child cant have animation in it, how do I get a cached bitmap to animate or move?

                         

                        I guess I just don't have enough experience to understand what your trying to say, to me, your answers seem to conflict with eachother

                        1 person found this helpful
                        • 9. Re: Whats the correct way to cacheasbitmap when animating on the timeline
                          kglad Adobe Community Professional & MVP

                          i don't see any conflicting info.

                           

                          the cached object can move left/right/up/down.  if published for air and using cacheasbitmapmatrix, it can also scale, rotatate, fade and skew. 

                           

                          but, if the cached object is a movieclip, that cached object should not have animation on the cached object's timeline.  ie, no children of the cached object are animating.

                           

                          the parent of the cached object should not be cached unless the parent is a candidate for caching (because it has no children that are animating).  in that situation only the parent needs to be cached.  there's no additional benefit (and there's a memory drawback) to caching children.

                          • 10. Re: Whats the correct way to cacheasbitmap when animating on the timeline
                            DKNMSIS Level 1

                            I was under the impression the cached object had to be a movieclip, how elce would I turn a vector object into a bitmap without making it a movieclip (movieclips are the only symbol that allows an instance name for me to specify it as a cacheasbitmap through actionscript)

                             

                             

                             

                            I think I may have been thinking that when you say "animation on it's timeline" i thought for some reason you ment animation on the timeline it is placed, not timeline inside the animation.

                             

                            sorry for the confusion, the terminology is difficult to grasp through text and not seeing an example.

                             

                             

                            and just to recap,
                            -cached object should not change it's frames, it should be a static object with no animation inside its timeline.
                            -caching as bitmap should just be done when object is moving x and y coords,
                            -caching as bitmap matrix should be done when being faded,scaled,rotated or skewed

                            -assign objects an instance name first then animate with keyframes and tweens later

                             

                             

                            having a container move/rotate objects that are cached wont work and will cache every frame reguardless of cacheasbitmap or matrix

                            • 11. Re: Whats the correct way to cacheasbitmap when animating on the timeline
                              kglad Adobe Community Professional & MVP

                               

                               

                              I was under the impression the cached object had to be a movieclip, how elce would I turn a vector object into a bitmap without making it a movieclip (movieclips are the only symbol that allows an instance name for me to specify it as a cacheasbitmap through actionscript)

                              that's incorrect.  all displayobject's have cacheasbitmap and  cacheasbitmapmatrix properties.  you're only considering display objects that can be created in the ide.  more types can be created with actionscript.

                               

                               

                               

                              I think I may have been thinking that when you say "animation on it's timeline" i thought for some reason you ment animation on the timeline it is placed, not timeline inside the animation.

                               

                              sorry for the confusion, the terminology is difficult to grasp through text and not seeing an example.

                               

                               

                              and just to recap,
                              -cached object should not change it's frames, it should be a static object with no animation inside its timeline.

                              correct.

                              -caching as bitmap should just be done when object is moving x and y coords

                              no, that should also be done when fading, scaling, rotating or skewing IF you're making an air app and you assign a cacheasbitmapmatrix.  cacheasbitmapmatrix is not needed if an object is only undergoing x,y changes.
                              -caching as bitmap matrix should be done when being faded,scaled,rotated or skewed

                              yes, but can only be done in air.

                              -assign objects an instance name first then animate with keyframes and tweens later

                              assign an instance name, add keyframes AFTER the keyframe where the object was initially added and assign an instance name.

                               

                               

                              having a container move/rotate objects that are cached wont work and will cache every frame reguardless of cacheasbitmap or matrix

                              no