`
SilverRing
  • 浏览: 72686 次
社区版块
存档分类
最新评论

[flex] Quotes from tips for performance

    博客分类:
  • Flex
阅读更多
1. Architecting Flex Applications That Perform Well

1) Use the Flex navigator containers (Accordion, TabNavigator, and ViewStack). Flex navigator containers help control the creation of child views with deferred instantiation.

2) Dashboard-style. This type of application organizes content into modular, self-contained views. This approach performs well because it organizes complex views, with Flex creating them when the user drills down.

2. Using Layouts, Hierarchy, and Containment Properly

The biggest Flex performance danger is yielding to the temptation to use containers randomly. Principle: Avoid unnecessary container nesting.

1) Avoid Nesting Containers Many Levels Deep

Below are an example of deeply nested code:

<mx:VBox>
  <mx:HBox>
    <mx:Form>
      <mx:FormItem>
       .....
       ...
      </mx:FormItem>
    </mx:Form>
  </mx:HBox>
</mx:VBox>


Typically, nesting fewer containers provides good results with respect to creation time.

2) Absolute Positioning and Sizing

The calculations to decipher how big each container and its children are, as well as where to place them, can potentially be resource-intensive. Here are two tips that can help reduce these calculations:

i.  Hard-code object positions

Absolute positioning does not work well if you want your application to resize when the browser window resizes. Using the Canvas container to create faster layouts should be a last-resort solution.

ii. Hard-code object widths and heights

This technique works with any container or control.

3) Use Grid Containers Wisely

You should only use a Grid container when your controls must line up both horizontally and vertically.

Some common misuses of Grid containers include the following:

a) Using the Grid container when you want to left-justify or right-justify controls in the same container (see Figure 3). Developers often try to do this using the following code:

<mx:Grid borderStyle="solid" width="400">
 <mx:GridRow>
  <mx:GridItem horizontalAlign="left">
   <mx:Button label="left" />
  </mx:GridItem>
  <mx:GridItem horizontalAlign="right">
   <mx:Button label="right" />
  </mx:GridItem>
 </mx:GridRow>
</mx:Grid>


However, using an HBox container with a Spacer object to fill unwanted space works the exact same way, as shown in the following snippet:

<mx:HBox borderStyle="solid" width="400">
  <mx:Button label="left" />
  <mx:Spacer width="100%" />
  <mx:Button label="right" />
</mx:HBox>


b) Using a Grid container as a child of a Repeater object when alternate mechanisms would work better. Alternatively, you can achieve it with a List control and a custom cell renderer.

3. Examples of Common Container Redundancies to Avoid

1) The VBox container inside an <mx:Panel> tag

A Panel container is a VBox container other Panel styles. For example, instead of writing this:

<mx:Panel title="Grocery List" width="150" height="150">
    <mx:VBox>  
        <mx:Label text="Fruits" />
        <mx:Label text="Veggies" />
        <mx:Label text="Cookies" />
    </mx:VBox>
</mx:Panel>


Use this code instead:

<mx:Panel title="Grocery List" width="150" height="150">
    <mx:Label text="Fruits" />
    <mx:Label text="Veggies" />
    <mx:Label text="Cookies" />
</mx:Panel>


2) VBox container inside an <mx:Application> tag

An Application object is inherently a VBox container layout.

3) Containers as top-level tags for MXML components

You do not need to use a container tag as the top-level tag of your MXML component definition. It is perfectly valid for an MXML component to be a simple control, like:

<mx:Image xmlns:mx=http://www.macromedia.com/2003/mxml source="@embed('foo.jpg')" width="200" height="200" />


4) Container wrappers for an MXML component instance

There is no need to wrap a container around an MXML component tag.

<mx:VBox backgroundColor=" #FFCCCC" borderStyle=" solid"> 
    <myComponent xmlns=" *" />
</mx:VBox>


can be changed to:

<myComponent xmlns=" *" backgroundColor=" #FFCCCC" borderStyle=" solid" />


5) Re-evaluate your container choices

4. Using Deferred Instantiation to Improve Perceived Performance

Containers have a creationPolicy property that you set to specify when Flex should create the container (at startup, incrementally, when a user navigates to that container, or based on other user action).

The following list explains what each creationPolicy property does when set on Flex navigator containers:

1) creationPolicy="auto"

on navigator containers: it loads quickly, but users experience a brief pause the first time they navigate from one view to another.
on non-navigator containers: must add extra code to specify when to create the container's children.

2) creationPolicy="all"

When Flex creates the navigator containers, it creates all of the controls in all their child views.

3) creationPolicy="none"

You explicitly instantiate views with the createComponents() method. Flex doesn't instantiate for you.

4) creationPolicy="queued"

Flex creates all containers and then creates the children of the queued containers in the order in which they appear in the application unless you specify a creationIndex property.

Progressive Layout—Queued Creation of Components

Progressive layout is similar to the way HTML applications load content in succession in a client.

More detailed info can be found here.

5. Handling Large Data Sets

Paging and sorting can be incorporated to handle large data sets.

6. Playing Complex Effects Smoothly

to be continued

7. Achieving Great Performance with Runtime Styles

to be continued

8. Improving a Repeater Object's Performance

to be continued

9. Performance Tuning and Profiling Your Own Flex Application

1) Use RSLs

2) Use the actionscript profiler

3) Calculate the intialization time

<?xml version="1.0" encoding="iso-8859-1"?>
<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" creationComplete="doLater(this,'doneNow')">
<mx:Script><![CDATA[
var dp = [{food:"apple", type:"fruit", color:"red"}, {food:"potato", type:"vegetable", color:"brown"}, {food:"pear", type:"fruit", color:"green"},
	{food:"orange", type:"fruit", color:"orange"},{food:"spinach", type:"vegetable", color:"green"},{food:"beet", type:"vegetable", color:"red"}];
function doneNow()
{
	doLater(this, "reallyDoneNow");
}
function reallyDoneNow()
{
	timerLabel.text += getTimer() + " ms"
}
]]></mx:Script>
<mx:Form>
	<mx:FormHeading label="Sample Form" />
	<mx:FormItem label="List Control">
		<mx:List dataProvider="{dp}" labelField="food"/>
	</mx:FormItem>
	<mx:FormItem label="DataGrid control">
		<mx:DataGrid width="200" dataProvider="{dp}"/>
	</mx:FormItem>
	<mx:FormItem label="Date controls">
		<mx:DateChooser />
		<mx:DateField />
	</mx:FormItem>
	<mx:FormItem label="Load Time">
		<mx:Label id="timerLabel" fontSize="12" fontWeight="bold" text="The application initialized in "/>
	</mx:FormItem>
</mx:Form>
</mx:Application>


4) Use getTimer() to time component and data gestures

Check out this blog entry.


Original Artical
分享到:
评论

相关推荐

    Quotes From a Friend-crx插件

    【 Quotes From a Friend-crx 插件 】是一款专为英文用户设计的浏览器扩展程序,其核心功能是在用户每次打开新标签页时显示著名激励大师Tony Robbins的励志名言。这款插件旨在通过每日的正能量注入,激发用户的生活...

    get_magic_quotes函数详解

    ### get_magic_quotes函数详解 在PHP环境中,处理输入数据的安全性是至关重要的,尤其是在Web开发领域。`get_magic_quotes_gpc()` 和 `get_magic_quotes_runtime()` 函数是PHP早期版本中用于自动转义用户提交的数据...

    Famous quotes from famous people-crx插件

    【Famous Quotes from Famous People - CRX 插件】是一个为英语(英国)用户设计的浏览器扩展程序,其主要功能是展示历史上著名人物的激励性名言。这款插件旨在为用户提供一个简单、便捷的方式,让他们在浏览网络时...

    记录 集合 BULK COLLECT FORALL 执行计划

    FORALL i IN quotes.FIRST..quotes.LAST UPDATE some_table SET column1 = quotes(i).symbol, column2 = quotes(i).bid WHERE id = quotes(i).id; ``` 在这个例子中,FORALL循环会根据quotes数组中的每一项更新...

    股票行情查看 - Stock quotes_v1.0.6.crx

    股票行情查看 - Stock quotes_v1.0.6.crx

    Scrapy爬取网站:Quotes to Scrape

    这是一个scrapy官方提供的网站:http://quotes.toscrape.com/ ,网页很简单,麻雀虽小五脏俱全。就用这个网站详细演示下Scrapy基础使用方法。参见博客:https://blog.csdn.net/qq_42776455/article/details/83116164

    Programming Quotes.txt

    Programming Quotes

    HistoricalQuotes.csv

    苹果公司的股票数据。

    quotes

    quotes

    Optimized C++ 原版pdf by Guntheroth

    One of my favorite quotes comes by way of a letter from Sir Isaac Newton, in which he writes, “If I have seen farther, it is by standing on the shoulders of giants.” I too have stood on the ...

    Quotes_1499268934132.pdf

    Quotes_1499268934132

    tdx market quotes getter

    "tdx market quotes getter" 是一个程序或工具,主要用于获取实时的股票市场报价。TDX,全称为通达信,是中国国内知名的金融数据提供商,提供包括股票、期货、期权等多种金融市场数据服务。这个工具可能是用来比较...

    基于magic_quotes_gpc与magic_quotes_runtime的区别与使用介绍

    可以使用set_magic_quotes_runtime()函数来控制magic_quotes_runtime的状态,设置为1表示开启,设置为0表示关闭。需要注意的是,magic_quotes_runtime在关闭状态下,从文件或数据库中读取的数据不会被自动转义,可能...

    Ajax 探密

    Ajax, the popular term for Asynchronous ... The book even addresses best practices for testing Ajax applications and improving maintenance, performance, and reliability for JavaScript code.

    Mathematics for Computer Science

    Ren′e Descartes, and it is one of the most famous quotes in the world: do a web search for it, and you will be flooded with hits. Deducing your existence from the fact that you’re thinking about ...

    前端开源库-typographic-quotes

    开源库“typographic-quotes”正是针对这一需求而设计的,它专注于提供优雅、规范的引号处理方案,确保在网页上始终使用正确的典型大引号。本文将深入探讨这个库的功能、使用方法以及其在实际项目中的应用。 ...

    Smart-Mirror-Magic-Mirror-App-with-weather-and-quotes-for-old-Android-devices:基于OpenWeatherMap的Web-App,具有地理位置,经过修改的预测和报价

    此外,从压缩包文件名称“Smart-Mirror-Magic-Mirror-App-with-weather-and-quotes-for-old-Android-devices-main”来看,其主要内容可能包含了源代码、资源文件以及项目配置等。开发者可以通过分析这些文件来学习...

    FlexGraphics_V_1.79_D4-XE10.2_Downloadly.ir

    editing the displaying of hint for flex-object within the object. - ADD: Added the protected-property TFlexPanel.GridControl - a flex-object for drawing grid on document. - FIX: The method ...

    php中get_magic_quotes_gpc()函数说明

    如果`magic_quotes_gpc`设置为开启,但开发者想要手动处理字符串转义,应当首先使用`get_magic_quotes_gpc()`检查当前状态。如果返回值为1,说明数据已经自动转义,这时再使用`addslashes()`就会导致双层转义,因此...

    plsqldev13.0.3.1902x32主程序+ v12中文包+keygen

    Using the Auto Refresh function in the SQL Window would prompt for substitution variable values for each refresh March 1, 2019 - Version 13.0.2 released Enhancements Performance and stability ...

Global site tag (gtag.js) - Google Analytics