FLEX example 例子

[color=red][b][size=medium]How to find an ArrayCollection item with a specific property value?[/size]牛!
[url]http://stackoverflow.com/questions/1566145/how-to-find-an-arraycollection-item-with-a-specific-property-value[/url][/b][/color]
上帖中有两种实现方式:一是通过Array的filter(),二是通过ArrayCollection的filterFunction;不得不说,这个帖子真好!下面是参考上帖后使用第一种方式的本地业务实现:[quote]
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;
}
}
[/quote]


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


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


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


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


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

<mx:Button label=”MyButton” enabled=”{(active1) && (active2)}” />
[/quote]


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



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


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


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


[b][size=medium]FLex datagrid list等的行style(背景色/字体/加粗等)设置:[/size][/b]
[b]通过itemrender让datagrid中选定的行的字体变粗:
Flex DataGrid Selected Row Styling:
[url]http://www.switchonthecode.com/tutorials/flex-datagrid-selected-row-styling[/url][/b]
List/ComboBox Row Backgrounds in Flex:
[url]http://www.barneyb.com/barneyblog/2007/06/22/listcombobox-row-backgrounds-in-flex/[/url]
[url]http://blog.csdn.net/terryzero/archive/2010/02/23/5321002.aspx[/url]
通过工厂去创建datagrid列的itemrender;适用为动态增加的datagridcolumn添加itemrender:
DIFFERENT ROWS IN DATAGRID – PROGRAMMATICALLY ADDED ITEMRENDERERS (CLASSFACTORY AND IFACTORY):
[url]http://www.flexer.info/2009/01/09/different-rows-in-datagrid-programmatically-added-itemrenderers-classfactory-and-ifactory/[/url]
Flex datagrid/advancedatagrid按条件显示行的背景颜色:
[url]http://blog.csdn.net/cfhacker007/archive/2010/08/03/5784523.aspx[/url]


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


[b][size=medium]设置s:NavigatorContent的vislble和includeInLayout:[/size][/b]
[url]http://stackoverflow.com/questions/3755806/flex-is-it-possible-to-hide-some-tabs-in-tab-navigator-and-show-them-only-when-c[/url][quote]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.[/quote]Flex - Hide and show tab in tabnavigator:
[url]http://whatsmytitletoday.blogspot.com/2009/06/flex-hide-and-show-tab-in-tabnavigator.html[/url][quote]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)
[/quote]


[b]Flex中ArrayCollection的克隆[/b]:
Cloning ArrayCollection:
[url]http://jodieorourke.com/view.php?id=105&blog=news[/url][quote]下面的方式,新的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 ); //方式二
[/quote]


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


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


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


Determining when an ArrayCollection changes in Flex:
[url]http://blog.flexexamples.com/2008/05/14/determining-when-an-arraycollection-changes-in-flex/[/url]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值