`

FLEX example 例子

    博客分类:
  • FLEX
阅读更多
How to find an ArrayCollection item with a specific property value?牛!
http://stackoverflow.com/questions/1566145/how-to-find-an-arraycollection-item-with-a-specific-property-value

上帖中有两种实现方式:一是通过Array的filter(),二是通过ArrayCollection的filterFunction;不得不说,这个帖子真好!下面是参考上帖后使用第一种方式的本地业务实现:
引用
protected function updateDevPosEventListener(event:Event):void
			{
				var win:AdjustDevicePosition = event.target as AdjustDevicePosition;
				//binding updated dev‘s position prop
				var newDeviceAC:ArrayCollection = win.deviceAC as ArrayCollection;
				for(var i:int=0; i<newDeviceAC.length; i++) {
					var newDeviceVo:FidsDeviceVo = newDeviceAC.getItemAt(i) as FidsDeviceVo;
					var deviceVo:FidsDeviceVo = findVoInDeviceAC(deviceAC, findId(newDeviceVo.id)) as FidsDeviceVo;
					deviceVo.position = newDeviceVo.position;
				}
				PopUpManager.removePopUp(win);
			}
			
			
			public function findVoInDeviceAC(c:ArrayCollection, find:Function):Object {
				var matches : Array = c.source.filter( find );
				return ( matches.length > 0 ? matches[0] : null );
			}
			
			public function findId(id:String):Function {
				return function( element:*, index:int, array:Array ):Boolean
				{
					return element.id == id;
				}
			}





Removing items from a Flex DataGrid control using the DragManager class:
http://blog.flexexamples.com/2008/04/16/removing-items-from-a-flex-datagrid-control-using-the-dragmanager-class/comment-page-1/#comment-9253




flex中的beanutil.copyproperties:
http://www.kensodev.com/2010/06/22/copy-object-properties-to-another-object-flex/




FLEX中的eval:
http://nsdevaraj.wordpress.com/2008/03/18/eval-in-as3/
引用
var functionName:String = “foo” + bar;
if (this.hasOwnProperty(functionName))
this[functionName]();





设置enable,可以用来简单的防止重复提交:
Disabling a Spark Application container in Flex 4:
http://blog.flexexamples.com/2009/08/14/disabling-a-spark-application-in-flex-4/
Disabling user input in a Flex Application:
http://blog.flexexamples.com/2008/02/20/disabling-user-input-in-a-flex-application/




为控件的 enabled={boolExp} 设置多个boolExp 且操作判断项:
http://thanksmister.com/?p=45
引用
或操作可以直接使用 enabled={boolExp1 || boolExp2}
但对且操作,直接使用&&(enabled={boolExp1 && boolExp2})会报错“The entity name must immediately follow the ‘&’ in the entity reference.”。解决办法如上贴所说两种:
<mx:Button label=”MyButton” enabled=”{(active1) ? (active2):false}” />

<mx:Button label=”MyButton” enabled=”{(active1) &amp;&amp; (active2)}” />





Flex StringValidator的maxLength可输入控件的maxChars 都是用来检测输入域输入的字符数的(一个中文就是一个字符)。这里给出一个检测输入域字节长度的方法:
private function getStrByteLen(sChars:String) : int { 
        return sChars.replace(/[^\x00-\xff]/g,"xx").length; 
} 





Trimming strings using the Flex StringUtil class’s trim() method:
http://blog.flexexamples.com/2007/09/07/trimming-strings-using-the-flex-stringutil-classs-trim-method/




当Datagrid中列非常多时,默认的横向滚动策略下,横向滚动条会是可伸缩的,导致纵向滚动条在可见区域中看不见,即使你配了 height="100%" width="100%";此时可通过为datagrid加上 minWidth参数设置(minWidth="像素数")让其横向滚动条的长度固定。
当datagrid列很多,数据量也很大时,datagrid的滚动条反映会很迟钝,凸显出严重的性能问题。解决大数据量/很多列 datagrid滚动性能问题的办法:
Flex Smooth Scrolling DataGrid:
http://hash-pipe.com/2008/11/flex-smooth-scrolling-datagrid/
http://blogs.adobe.com/aharui/2008/11/faster_datagrid_horizontal_scr.html





动态调整DataGrid列的显示:
http://www.cnblogs.com/ping58/archive/2010/05/27/1745579.html




FLex datagrid list等的行style(背景色/字体/加粗等)设置:
通过itemrender让datagrid中选定的行的字体变粗:
Flex DataGrid Selected Row Styling:
http://www.switchonthecode.com/tutorials/flex-datagrid-selected-row-styling

List/ComboBox Row Backgrounds in Flex:
http://www.barneyb.com/barneyblog/2007/06/22/listcombobox-row-backgrounds-in-flex/
http://blog.csdn.net/terryzero/archive/2010/02/23/5321002.aspx
通过工厂去创建datagrid列的itemrender;适用为动态增加的datagridcolumn添加itemrender:
DIFFERENT ROWS IN DATAGRID – PROGRAMMATICALLY ADDED ITEMRENDERERS (CLASSFACTORY AND IFACTORY):
http://www.flexer.info/2009/01/09/different-rows-in-datagrid-programmatically-added-itemrenderers-classfactory-and-ifactory/
Flex datagrid/advancedatagrid按条件显示行的背景颜色:
http://blog.csdn.net/cfhacker007/archive/2010/08/03/5784523.aspx






Flex使用弹出窗口为DataGrid添加新数据:
http://www.iteye.com/topic/356788






设置s:NavigatorContent的vislble和includeInLayout:
http://stackoverflow.com/questions/3755806/flex-is-it-possible-to-hide-some-tabs-in-tab-navigator-and-show-them-only-when-c
引用
Use the TabNavigator's getTabAt() method which returns the Button that makes up the visual tab and set the visible property to false. It can be tricky with bindings.
Flex - Hide and show tab in tabnavigator:
http://whatsmytitletoday.blogspot.com/2009/06/flex-hide-and-show-tab-in-tabnavigator.html
引用
This becomes very important if you want to hide tabs in a tab navigator but you don't want to remove them from the interface completely. In my situation I wanted to hide tabs in a tab navigator based on what the user had selected in a data grid. If the user selected another row in the grid I may need to show a tab that I had previously hidden.
tabNav.getTabAt(1).visible = false;
Now to elaborate on Venkatesh's post...
To remove the tab stop, also disable it:
tabNav.getTabAt(1).enabled = false;
Now if you are hiding a tab before another tab (that is not hidden) there will be an empty gap where your tab should be. To fix this:
tabNav.getTabAt(1).includeInLayout = false;
And one final thing. If you're hiding your default tab (i.e. tab index 0) you will also need to set the selected index of the tabNav or else you will still see the contents of the default tab.
tabNav.selectedIndex = 2; //If you were hiding the first 2 tabs (tab 0 and tab 1)







Flex中ArrayCollection的克隆
Cloning ArrayCollection:
http://jodieorourke.com/view.php?id=105&blog=news
引用
下面的方式,新的arraycollection和旧的使用的是同一个source,所以对任一arraycollection做增删操作,另一个会跟着变化
var newAC:ArrayCollection = new ArrayCollection( originalAC.source ) ); 
想做深度的克隆,即让源arraycollection和克隆出的arraycollection在克隆会使用不同的array作为source,从而达到对两个arraycollection的操作互不影响的目的,可以使用以下两种方式:
private function clone( source:Object ) :*
{
var myBA:ByteArray = new ByteArray();
myBA.writeObject( source );
myBA.position = 0;
return( myBA.readObject() );
}
var newAC:ArrayCollection = new ArrayCollection( clone( originalAC.source ) );  //方式一

var myAC:ArrayCollection = new ArrayCollection( ObjectUtil.copy( originalAC.source ) as Array );   //方式二






为一个arrayCollection指定多个filterFunction:
ArrayCollection with multiple filter functions:
http://blog.rotundu.eu/flex/arraycollection-with-multiple-filter-functions/





Finding substrings and patterns in strings:
http://livedocs.adobe.com/flex/3/html/help.html?content=09_Working_with_Strings_09.html






TabBar 和 LinkBar例子:
http://learn.adobe.com/wiki/display/Flex/TabBar+and+LinkBar





Determining when an ArrayCollection changes in Flex:
http://blog.flexexamples.com/2008/05/14/determining-when-an-arraycollection-changes-in-flex/
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics