3 Replies Latest reply: Sep 25, 2009 10:04 AM by mucatron RSS

    Flash Lite Optimization - attachMovie vs Timeline

    Thommasc Community Member

      Give us your opinion about how you define a Flash Lite project for a complex application with many different views.

       

      Do you use :
      1) attachMovie with each different views in movie clips in the library
         unloadMovie to switch to another view
      ?

       

      2) timeline ... you use gotoAndStop() ?
          the main problem of this, is when you use createEmptyMovieClip(),
          created movieclips won't be removed when you gotoAndStop() to another keyframe even if it is separated from the previous one.

       

      I tried solution n°2
      Timeline becomes fast overloaded.
      Moreover, I learn that you need to put many empty frames to let Flash Lite initialize properly ... if you put 1 keyframe for each view from the very beginning of your timeline, your AS code will be buggy.

       

      I'm now going to use solution n°1.

       

      Tell us about your Flash Lite experience and mobile application architecture.

      Thx !

        • 1. Re: Flash Lite Optimization - attachMovie vs Timeline
          mucatron Community Member

          In terms of optimization the best method to ensure memory efficiency is to use loadMovie with a depth property.  You should continue to load new movies into the same depth to ensure memory is recovered.

           

          Alternatives are to load all movies at movie.x = -1000 to load the movie into memory but keep it off the display list.  When you are ready to display the movie you can move it closer to the stage, or on to the stage.

           

          A deep display list of movie clips will slow down performance, so try to ensure that most movies are in the same depth.

           

          unloadMovie or unloadClip may cause memory leaks under some conditions, so it's important to manage the references to these objects and those inside them carefully.

           

          If you are using XML please also ensure that you call delete xml.idMap before delete xml to ensure that the xml document is removed correctly.

           

          Good luck!

           

          Mark

          www.flashmobileblog.com

          • 2. Re: Flash Lite Optimization - attachMovie vs Timeline
            Thommasc Community Member

            "In terms of optimization the best method to ensure memory efficiency is to use loadMovie with a depth property.  You should continue to load new movies into the same depth to ensure memory is recovered."

            Are you meaning we should never use "this.getNextHighestDepth()" but use always an integer (0 or 2 for example) instead ?

             

            "Alternatives are to load all movies at movie.x = -1000 to load the movie into memory but keep it off the display list.  When you are ready to display the movie you can move it closer to the stage, or on to the stage."

            Loading all movies would be cpu expensive, would not it ? We don't need to load 10 different views at the same time.

            But it might be good to have 2 or 3 movieclip of different view loaded so we can't switch instantly between them using _x or _y.

             

            "A deep display list of movie clips will slow down performance, so try to ensure that most movies are in the same depth."

            By depth are you meaning "depth" (swapDepths and depth parameter in loadMovie) ? or putting movie clip one into another ?

            What about layers ? I found out that layer order influences the depth of movieclips. Is there a link between layer and depth parameter of movieclips ?

             

            "unloadMovie or unloadClip may cause memory leaks under some conditions, so it's important to manage the references to these objects and those inside them carefully."

            Can you tell us a bit more about commonly known leaking issue ?

             

            "If you are using XML please also ensure that you call delete xml.idMap before delete xml to ensure that the xml document is removed correctly."

            >> please also ensure that you call delete xml.idMap before delete xml

            What do you mean exactly ? Can you give us the AS2 code to do so ?

            What is idMap ?

             

            Thx for all these great explanations !

            • 3. Re: Flash Lite Optimization - attachMovie vs Timeline
              mucatron Community Member

              "In terms of optimization the best method to ensure memory efficiency is to use loadMovie with a depth property.  You should continue to load new movies into the same depth to ensure memory is recovered."

              Are you meaning we should never use "this.getNextHighestDepth()" but use always an integer (0 or 2 for example) instead ?

              Markd - Yes, try and load images or movies into known depths to be more efficient.  This is particularly useful for Gallery applications or lists.

               

              "Alternatives are to load all movies at movie.x = -1000 to load the movie into memory but keep it off the display list.  When you are ready to display the movie you can move it closer to the stage, or on to the stage."

              Loading all movies would be cpu expensive, would not it ? We don't need to load 10 different views at the same time.

              But it might be good to have 2 or 3 movieclip of different view loaded so we can't switch instantly between them using _x or _y.

              Markd - Once all the Movies are loaded you will have a good understanding of the top line memory requirements.  If this is within the limit of the device then you should be good to go.  You might consider loading the first 5 views, but remember to keep them well away from the stage at -1000 pixels or the player will add these to the display list and even if they aren't visible.

               

              "A deep display list of movie clips will slow down performance, so try to ensure that most movies are in the same depth."

              By depth are you meaning "depth" (swapDepths and depth parameter in loadMovie) ? or putting movie clip one into another ?

              What about layers ? I found out that layer order influences the depth of movieclips. Is there a link between layer and depth parameter of movieclips ?

              Markd - I meant on the same layer and potentially at the same depth (it's the same thing).  That might not be suitable for your app, but it's worth considering.

               

              "unloadMovie or unloadClip may cause memory leaks under some conditions, so it's important to manage the references to these objects and those inside them carefully."

              Can you tell us a bit more about commonly known leaking issue ?

              Markd - Fortunately these are now fixed but there are known leaks with unloadMovie, subString and within XML.  You will be unlikely to see them unless your application is very complex and you are using alot of RAM.

               

              "If you are using XML please also ensure that you call delete xml.idMap before delete xml to ensure that the xml document is removed correctly."

              >> please also ensure that you call delete xml.idMap before delete xml

              What do you mean exactly ? Can you give us the AS2 code to do so ?

              What is idMap ?

              Markd - idMap is a reference tree of all the nodes in an XML object.  Unfortunately if you deleted the XML object the idMap property stays around, and this is equal to the size of the XML object.  To avoid that you can copy over the existing XML object or call delete myXML.idMap or delete myXML["idMap"] before calling delete myXML.

               

              Thx for all these great explanations !