and Flash's development environment, Flex provides a component library is really tempting, but because the function is too comprehensive, resulting in large program size, sometimes improper use, may affect the efficiency of the program.
In the Flex Help manual, there is a special chapter on program optimization, and here are a few things I can do with help:
1, avoid the container of multi-level nesting, reduce relative size, relative positioning of the use.
The percentage is used to set the size of the components within the container, and once any one of the components in the container changes in position and size, it will cause the container to reposition all the children. If the nesting level is very deep, this calculation will be very large.
2. Use lightweight containers as much as possible
Canvas is the smallest container, and it only supports absolute positioning. Many times, you can use it instead of Hbox and VBox. In addition, canvas is also the first choice for us to write custom container-nature components. It has the basic function of the container, which facilitates the expansion.
3, avoid the use of large volume components, such as DataGrid, Advanceddatagrid
Large components are powerful, but expensive. Because of the complexity of the function, the realization of skin, style and itemrenderer is extremely complicated.
4, the processing of data more than the way to use pagination
When working with data type controls, minimize the amount of data displayed at once. For example Tilelist, it will create all the data at once, whether it is required to display, this is a waste of resources. Viewstack, Tabnavigator, etc. when processing a component, it is not created once, so that the unnecessary overhead is avoided as long as the component is created the first time it is displayed.
5, SetStyle and StyleName
The skin of the Flex component is a visual component that, when initialized by itself, uses the current style, such as stylename, to draw all skin components. If we modify the style of the component through SetStyle during run time, the size and position of the component will be adjusted accordingly. If the component is in a very deep container, there is also a large amount of computation.