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
,还有一个建议就是我们平要使用Repeater去处理要记得用recycleChildren设置可重用,count设置可重用控件数量,避免产生N多控件,程序死掉。
建议学习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" creationComplete="init()">
<mx:Script>
<![CDATA[
import flash.net.navigateToURL;
private function setCookie():void{
&nb ......
登陆页面
<?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.messages.HTTPRequestMessage;
import mx.rpc.http.HTTPService;
import mx. ......
==============flex===========
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" initialize="Service.GetCustomers.send();" width="689" height="592">
<mx:WebService id="Service" wsdl="ht ......
commpent
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml"
creationComplete="initApp()" backgroundDisabledColor="#EEC6C6"
bord ......
一、
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
addedToStage="stage.addEventListener(KeyboardEvent.KEY_DOWN, myKeyDown)"
click="clickEvt(event)"
layout="absolute"
&nb ......