1 Reply Latest reply on Nov 14, 2009 11:21 PM by Flex harUI

    Best way to keep CPU from freezing.

    flairjax Level 1

      So I have a Flex 4 app that is very processor intensive around 1000 objects each with their own embedded swf's coupled with drawing api and can't use cacheAsBitmap as things are moving and morphing.

      Anyway, I had a couple of ideas but didn't know if they would help much or make things worse.

      #1. Would it make a difference to set StageQuality = LOW when things are moving and the set StageQuality = HIGH when things stop moving/transition?

      #2. The other idea is that about 500 of the 1000 items on the stage are not shown all the time (user has zoomed in; think Google Maps), so would it help out to remove the embedded swf's, on the 500 of the visible stage area, and then re-embed when they are visible on stage? If so I was thinking adding an eventlistener to each of the 1000 items to recognize when off stage or have some control that recognizes the zoom or drag and then starts embedding the swf's in the 1000 items if they are with in the viewable stage are. But then I think wouldn't this make things worse since items would be embedded and re-embedded over and over? Or would it make things better as leaving them embedded and redrawing them when dragged or transitioned on every frame exit?

      Probably lost you.

      TIA, Jason

        • 1. Re: Best way to keep CPU from freezing.
          Flex harUI Adobe Employee

          An embedded SWF becomes a DisplayObject.  Instead of re-instantiating and embedded SWF, it is probably better to remove it from its parent, remember that you've already instantiated it, and re-add it when needed.


          The fewer display objects on stage the better.  Visible=false helps a little but not as much as removal.


          Also consider tricks.  I'd probably get dizzy watching 500 things in motion.  If lots of things really aren't moving, make a bitmap of those things.  If lots of things are all going in the same direction, you could create a bitmap out of them and move them as one big bitmap.  Things in motion may not need to be displayed at high resolution.


          Alex Harui

          Flex SDK Developer

          Adobe Systems Inc.

          Blog: http://blogs.adobe.com/aharui