zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    打印java 对象信息的小技巧
    git 忽略已经跟踪文件的改动
    mysql主从备份方案
    Lucene4.3和Lucene3.5性能对比(二)
    Lucene4.3和Lucene3.5性能对比(一)
    Cracking the coding interview--Q1.1
    CRACKING THE CODING INTERVIEW 笔记(1)
    关于名称重整(name mangling)、多态性的一些简单介绍
    shell中sed用法
    GDB调试GCC(jRate)
  • 原文地址:https://www.cnblogs.com/zhugexiaobei/p/3223132.html
Copyright © 2011-2022 走看看