• flex学习笔记 使用函数,显示实时更新的标签


    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                   xmlns:s="library://ns.adobe.com/flex/spark" 
                   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
      <s:layout>
          <s:VerticalLayout/>
      </s:layout>
        <fx:Script>
            <![CDATA[
                private function concatenateName(item:Object):String
                {
                 return item.firstName + " "+item.lastName;
                }
                    
            ]]>
        </fx:Script>
        
        <s:ButtonBar id="buttonBar" labelFunction="concatenateName">
            <mx:ArrayCollection>
                <fx:Object firstName ="马" lastName="楠" email="tahmed@flexinaction.com" phone="18815654512" />
                <fx:Object firstName ="张" lastName="士鑫" email="zhangshixin@xiangm" phone="188156545103" />
                <fx:Object firstName ="马" lastName="楠" email="tahmed@flexinaction.com" phone="18815654512" />
                <fx:Object firstName ="张" lastName="士鑫" email="zhangshixin@xiangm" phone="188156545103" />
                <fx:Object firstName ="马" lastName="楠" email="tahmed@flexinaction.com" phone="18815654512" />
            </mx:ArrayCollection>
        </s:ButtonBar>
    </s:Application>
    View Code

    2使用多列标签函数

    <?xml version="1.0" encoding="utf-8"?>
    <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                   xmlns:s="library://ns.adobe.com/flex/spark" 
                   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
      <s:layout>
          <s:VerticalLayout/>
      </s:layout>
        <fx:Script>
            <![CDATA[
                import mx.collections.ArrayCollection;
                import mx.controls.dataGridClasses.DataGridColumn;
                [Bindable]
                public var myAC:ArrayCollection = new ArrayCollection([
                    {name:"马楠", username:"manan",dtJoined:"01/02/2008 12:22:11",dtLogin:"02/20/2010 13:33:11"},
                    {name:"白小羽", username:"baixiaoyu",dtJoined:"01/02/2008 12:22:11",dtLogin:"02/20/2010 13:33:11"},
                    {name:"马a", username:"manan",dtJoined:"01/02/2008 12:22:11",dtLogin:"02/20/2010 13:33:11"},
                    {name:"马b", username:"manan",dtJoined:"01/02/2008 12:22:11",dtLogin:"02/20/2010 13:33:11"},
                    {name:"马c", username:"manan",dtJoined:"01/02/2008 12:22:11",dtLogin:"02/20/2010 13:33:11"}
                ]);
                
                public function formatDate(row:Object, col:DataGridColumn):String
                {
                  var retVal:String ="";
                  if(col.dataField =="dtJoined") retVal = dFmt.format(row.dtJoined);
                  else if (col.dataField =="dtLogin")
                       retVal = dFmt.format(row.dtLogin);
                  return retVal;
                }
                
            ]]>
        </fx:Script>
        <fx:Declarations>
            <mx:DateFormatter id="dFmt" formatString="MM/DD/YY"/>
        </fx:Declarations>
          <mx:DataGrid id="dg" width="500" height="100" dataProvider="{myAC}">
              <mx:columns>
                  <mx:DataGridColumn dataField="name" headerText="Name"/>
                  <mx:DataGridColumn dataField="username" headerText="Username"/>
                  <mx:DataGridColumn dataField="dtJoined" headerText="Joined" labelFunction="formatDate"/>
                  <mx:DataGridColumn dataField="dtLogin" headerText="Last login" labelFunction="formatDate"/>
              </mx:columns>
          </mx:DataGrid>
        
    </s:Application>
    View Code

  • 相关阅读:
    设计模式 --> (3)策略模式
    设计模式 --> (2)单例模式
    设计模式 --> (1)工厂模式
    Algorithm --> 十大排序算法
    Algorithm --> 求阶乘末尾0的个数
    网络通信 --> epoll用法
    数据库 --> sqlite3之api使用
    网络通信 --> select()用法
    网络通信 --> TCP三次握手和四次挥手
    『转载』周立功:专注的力量成就梦想
  • 原文地址:https://www.cnblogs.com/zhugexiaobei/p/3223132.html
Copyright © 2020-2023  润新知