加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

flex入门学习之十三动态DataGrid 和timer应用

发布时间:2020-12-15 05:03:11 所属栏目:百科 来源:网络整理
导读:?xml version="1.0" encoding="utf-8"? mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600" creationComplete ="application1_creationCompleteHandler(event)" ?加红部分类似于程序加载去运行的

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600"creationComplete="application1_creationCompleteHandler(event)" >
?加红部分类似于程序加载去运行的方法
?<mx:Script>
??<![CDATA[

??import mx.events.CollectionEvent;
???public var tim:Timer
???
???????????public var countt:int=0
???protected function ontime(evt:TimerEvent):void{ 每次执行都为array 添加
????var now:String = new Date().toTimeString();
??????????????? dongtai.addItem({id:1,time:now});

???}
???
???protected function dongtai_collectionChangeHandler(event:CollectionEvent):void 每次改变array都滚动到最下方
???{
????// TODO Auto-generated method stub
???
????????????????????autoScroll():

???}

?


?private function autoScroll():void {
??????????????????? if (dataGrid) {
???????????????????????? dataGrid.validateNow();
?????????????????????? dataGrid.verticalScrollPosition = dataGrid.maxVerticalScrollPosition;
????????????????? }
?????????? }???
???protected function application1_creationCompleteHandler(event:FlexEvent):void
???{
????// TODO Auto-generated method stub
????tim=new Timer(1000);
????tim.addEventListener(TimerEvent.TIMER,ontime) 为time创建执行方法
????tim.start()
???}
???
??]]>
?</mx:Script>

<mx:DataGrid x="409" y="172" id="dataGrid" dataProvider="{dongtai}">
???<mx:columns>
????<mx:DataGridColumn dataField="id" headerText="列 1"/>
????<mx:DataGridColumn dataField="time" headerText="列 2"/>
???
???</mx:columns>
??</mx:DataGrid>
??

??
?
<mx:ArrayCollection id="dongtai" collectionChange="dongtai_collectionChangeHandler(event)">
?
</mx:ArrayCollection>

</mx:Application>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读