Jump to content

Flex/ Flash Optimization

rtandon2006's Photo
Posted Nov 04 2009 10:07 AM
5210 Views

How can we optimized flash flex based applications.
In case of gaming and animation, flash rocks.
In term of data centric application, pagination and caching, what are the ways we can optimized flex based applications.

Tags:
2 Subscribe


2 Replies

+ 1
  Amy B's Photo
Posted Nov 18 2009 09:06 AM

Typed objects perform better than "generic" objects or XML. AMF compresses data that is being transmitted, so it transfers more quickly. View components that extend UIComponent are more efficient than classes that extend Container (this is most important when working with repeated components, like itemRenderers).

Do you have something specific you're interested in optimizing? These are general guidelines, but it's hard to know exactly what you have or haven't tried to answer your question.
0
  florian.salihovic's Photo
Posted Sep 22 2010 02:10 PM

In order to optimize your application, you need to find the bottlenecks first. There are some things you might want to avoid, like a heavy use of data binding for example in mxml. While it is a convenient feature, there are also some drawbacks.
  • Strong references: when done wrong - and by that i'm talking about really wrong, you can get memory leaks, since the event handers generated by the mxmlc is generating code without weak references... no garbage collection.
  • Lots of generated stub code for deep binding chains: just think of deep binding chains:
    <mx:Label text="{a.b.c.d.e}"/>
    You get a few of handlers generated.
  • Hard to debug: the closures for bindings are generated in the global namespace. The stacktrace you might want to check when data is set or modified, is useless...
  • The generic PropertyChange event. When a property is annotated as bindable, flex will generate code which dispatches a PropertyChange event. It is best practise to define properties this way:
    private var _selectedItem:Object;
    public function get selectedItem():Object
    {
      return _selectedItem;
    }
    [Bindable("selectedItemChanged")]
    public function set selectedItem(value:Object):void
    {
      if (_selectedItem === value) return;
    
      _selectedItem = value;
      dispatchEvent(new Event("selectedItemChanged"));
    }
    The check in the setter is made to avoid side effects and the dispatching of too many events. Just dispatch the event when the value and reference really changed
  • Understand the component live cycle. This is the heart of flex which every developer needs to understand.
  • Avoid deep container nestings. Flex will take care of the layout but you should try to keep the job simple to avoid to many measurings and updates of the display hierarchy.

Just some input... i hope it is helpful for one or the other.