Flex 自定义事件

//类 *.as

package classes.valueObjects
{
 [Bindable]
 public class Haha
 {
  public var userName:String;
  public var passWord:String;
  public function Haha()
  {
  }
 }
}

 

 

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="horizontal" initialize="init()">
 <mx:Script>
  <![CDATA[
   import classes.valueObjects.Haha;
   import mx.rpc.events.ResultEvent;
   import mx.events.ResourceEvent;
   import mx.collections.ArrayCollection;
   
   private function init():void{
    submit.addEventListener(MouseEvent.CLICK,onSubmit);
   }
   private function onSubmit(event:MouseEvent):void{
   // datas.send();
    hahaViews();
    datas.visible=true;
   }
   private function hahaViews():void{
    textData = new ArrayCollection;
    var haha1:Haha = new Haha();
    haha1.userName = "111";
    haha1.passWord = "111"
    var haha2:Haha = new Haha();
    haha2.userName = "222";
    haha2.passWord = "222";
    textData.addItem(haha1);
    textData.addItem(haha2);
   }
   [Bindable]
   private var textData:ArrayCollection;

  ]]>
 </mx:Script>
 <mx:Metadata>
  [Event(name="MyEvent",type="flash.events.Event")]
 </mx:Metadata>
 <mx:DataGrid dataProvider="{textData}" id="datas"
   visible="false">
  <mx:columns>
   <mx:DataGridColumn dataField="userName" headerText="用户名"/>
   <mx:DataGridColumn dataField="passWord" headerText="密码"/>
  </mx:columns>
 </mx:DataGrid>
 <mx:Button label="submit" id="submit" click="onSubmit(event)"/>
 
</mx:Application>

 

//自定义事件 必须继承flash.events.Event类   [Event(name="MyEvent",type="flash.events.Event")]

你可能感兴趣的:(function,datagrid,Flex,application,button,encoding)