Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

10 Tips for Flex Application Performance

We're going to keep this post lean and mean, and get down to
business with 10 Tips that will keep your Flex applications fast, lean,
and responsive.
Rule # 1: Clean up after yourself
In general, it is good practice to maintain clean code. Not only
in the sense of having properly formatted and readable code, but also
code that leaves nothing behind... no memory leaks, no cpu hogs,
nothing but a clean object that can be reclaimed by the GC.
1) Manage your event listeners
- this message is
two fold. First, you should always remove event listeners that are no
longer needed. They can lead to object references that prevent the
garbage collector, which equates to memory leaks, which can be very
difficult to track down and detrimental to application performance. You
can use weakly referenced event listeners to minimize memory leakage,
but you still should explicitly clean them up when you don't need them
anymore. The second factor is that failure to remove event listeners
can cause performance issues. Event handlers could be firing within
your application, which you weren't even aware of. You dispatch an
event in a child component, and there could be handlers up the DOM tree
(parent objects) that are also firing on the same event. If you don't
want this to happen, be explicit with your event handlers; make them
handle specific event types, and get rid of them when your application
doesn't need them anymore.
2) Unload loaders
- any time that you are using an
object based on a loader (Image, SWFLoader, etc...), it's a good
practice to call unloadAndStop() to unload the content from the loader,
and invoke the GC. This will free up valuable system resources and cpu
cycles won't be wasted if they aren't needed. I typically even do this
for static image files, to prevent memory usage from creeping up.
3) Dispose of things
- I find it to be a very good
practice to create "dispose()" functions in your custom components,
data managers


Ïà¹ØÎĵµ£º

flexѧϰ µ¼º½

¼¸ÖÖµ¼º½Ñ¡Ï
  <?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
<mx:ButtonBar dataProvider="myPages">
</mx:ButtonBar>
<mx:ToggleButtonBar dataProvider="myPages">
</mx:ToggleButto ......

Flexʼþ»úÖÆ

Flexʼþ»úÖÆ
Flexʼþ»úÖÆÊǹ۲ìÕßģʽ£¬¼´Ê×ÏÈҪע²áʼþ£¬Ê¼þ·Ö·¢ºóͨ¹ýʼþÏìÓ¦º¯Êý½øÐд¦Àí¡£
ÀýÈçÔÚAS3ÖУº
button.addEventListener(“click”,onClick);//Ïòbutton×¢²áÒ»¸öclickʼþ
internal function onClick(evt:MouseEvent):void{txt.text=“click a button!”;}//ʼþÏìÓ¦º¯Êý
ÄÇÃ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ