易截截图软件、单文件、免安装、纯绿色、仅160KB

flex repeater控件Repeater is not executing"的异常


flex repeater控件注意
Repeater 顾名思义,Repeat就是重复的意思, Repeater 就是用来重复的控件
Repeater 会根据数据源中对象的多少来产生多少个子项,生成的子项全部是以数组形式存在的
<mx:Repeater id="myRepeater" dataProvider="{myArray}">
        <mx:HBox>
        <mx:LinkButton id="myLabel" label="{myRepeater.currentItem.name}" click="show(event.currentTarget.getRepeaterItem())"/>
        <mx:TextInput text="{myRepeater.currentItem.age}"/>
        </mx:HBox>
</mx:Repeater>
有个常见的问题:
发现没有,我们平时调用函数时传递Repeater 中的字段作为参数时,是不可以传递的会出现" Repeater is not executing"的异常
但是有getRepeaterItem()这个东东,是解决这个问题的最好的方案
甚至我们不需要传递getRepeaterItem()
传递一个event过去就好了,使用event.currentTarget.getRepeaterItem(),
同样可以获得当前对象的currentItem
,还有一个建议就是我们平时如果能用DataGrid解决的,就不要使用Repeater去处理,Repeater在效率会上大打折扣
建议学习flex的人去http://livedocs.adobe.com/flex/3/html/index.html官方flex文档去看看
虽然英文不好,但是代码我们总能看懂,对学习flex的人大有裨益
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
<!--[CDATA[
import mx.messaging.AbstractConsumer;
import mx.collections.ArrayCollection;
private var my:Array=[{name:"a",age:1},{name:"b",age:2},{name:"c",age:3}];
[Bindable]
private var dp:ArrayCollection=new ArrayCollection(my);
]]-->
</mx:Script>
<mx:VBox x="144" y="118" width="319" height="224">
<mx:Repeater id="rp" dataProvider="{dp}">
<mx:RadioButton label="{rp.currentItem.name}" click="aa.text=event.target.getRepeaterItem().age"/>


</mx:Repeater>
<mx:TextInput id="aa"/>
</mx:VBox>
</mx:Application>


相关文档:

Flex no.2

--------------ex2_01_solution  选取时间-----------------------
 ...
   private function dateChangeHandler():void
   {
    // The Alert.show() message displays a static string plus the selected date in the startDate control
   ......

常用的Flex代码总结

常用的Flex代码总结
1.刷新浏览器

  navigateToURL(new URLRequest("javascript:location.reload();"),"_self")

  2.关闭浏览器

  navigateToURL(new URLRequest("javascript:window.close()"),"_self");

  3.打开一个新浏览器窗口

  navigateToURL(new URLRequest('ht ......

flex 使用RSL减小swf的体积,以及遇到的问题

在开发项目时,项目越大,swf生成的体积越大,对于局域网影响不大,但是对于互联网就很头疼了。
加载一个界面要很久。一般人根本没耐性等你加载完。
为了减小swf体积,个人总结了两个办法。办法如下:
第一,尽量使用module,少量使用自定义组件,这样可以减少加载的时间
第二,使用RSL,减小swf体积。RSL使用如下:
� ......

flex快捷键大全

Ctrl-F11: 执行(Run)
F11: 除错(Debug)
Ctrl-Alt-Down: 重复目前所在编辑列(Repeat current line )
Alt-Up: 移动本列,或选择列往上移动(Move line (or selection) up )
Alt-Down: 移动本列,或选择列下往移动(Move line (or selection) down )
Ctrl-Click: 移至定义区(Go to definition (also F3) ) ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号