外部调研类
package com.jspx.flex { import mx.controls.Alert; import mx.events.FlexEvent; public class TestAlert { public function showAlert():void { Alert.show("测试外部研类"); } } }
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"> <fx:Declarations> </fx:Declarations> <fx:Script> <![CDATA[ import com.jspx.flex.TestAlert; protected function alertInfo():void { var ta:TestAlert = new TestAlert(); ta.showAlert(); } ]]> </fx:Script> <s:Label x="36" y="36" text="XYZ Corporation Directory" color="maroon" fontSize="20" fontWeight="bold"/> <s:Button x="36" y="85" label="对话框" id="empBtn" click="alertInfo()"/> <s:Button x="223" y="86" label="测试2" id="deptBtn"/> <mx:DataGrid x="36" y="114" id="empDg" width="500" editable="true"> <mx:columns> <mx:DataGridColumn headerText="第一行" dataField="col1"/> <mx:DataGridColumn headerText="第二行" dataField="col2"/> <mx:DataGridColumn headerText="第三行" dataField="col3"/> </mx:columns> </mx:DataGrid> </s:Application>
事件可以如同javascript一样调研,类的载入和java比较类似,
函数表示方式为:public function showAlert():void