我的as代码是这样的:
package com.ysds.sysconf.control { public class DTAttrDefineAs { public function DTAttrDefineAs() { } import ui.userObject.objDTAttrDefineOperTitle; import com.ysds.StrTools; import flash.net.registerClassAlias; import flash.utils.getDefinitionByName; import mx.managers.DragManager; import mx.managers.PopUpManager; import util.ImportUtil; private var popUpManager:PopUpManager; private var dragManager:DragManager; import mx.managers.HistoryManager; var historyManager:HistoryManager; import util.ModelLocator; import flashx.textLayout.tlf_internal; import flexlib.scheduling.scheduleClasses.utils.Selection; import flexunit.utils.ArrayList; import mx.collections.ArrayCollection; import mx.collections.ArrayList; import mx.controls.Alert; import mx.controls.dataGridClasses.DataGridItemRenderer; import mx.core.IFlexDisplayObject; import mx.events.ItemClickEvent; import mx.events.ListEvent; import mx.managers.PopUpManager; import mx.messaging.management.Attribute; import mx.rpc.events.ResultEvent; import org.hamcrest.mxml.collection.InArray; import spark.components.List; import spark.components.TitleWindow; import spark.components.supportClasses.ItemRenderer; import util.ExportExcel; import util.ModelLocator; import vo.AttributeDefine; private var dTAttrDefineOperBD:objDTAttrDefineOperTitle = null; [Bindable] private var attributeDefineList:ArrayCollection = new ArrayCollection(); [Bindable] private var attributeDefineVO:AttributeDefine = new AttributeDefine(); [Bindable] private var adid:String = new String(); //保存用户选择的行的主键值 private var adidSize:int =new int(); //保用用户选择的行数 /**** * 进行初始化的操作 * 查询list集合进行显示 * */ private function init():void{ // moduleLoader.applicationDomain = ApplicationDomain.currentDomain ; tDTAttributeDefineService.selectAllAttributeDefineList(); } /**** * 查询list集合之后进行 * 返回值在这里进行操作 * */ private function result_selectAllAttributeDefineList(event:ResultEvent,str:String):void{ if(str == 'AttributeDefine'){ //查询的DataGrid中需要的List集合 attributeDefineList = event.result as ArrayCollection ; }else if(str == 'AttributeDefineDelete'){//删除后的操作 try{ var resultObject:int = parseInt(event.result as String) ; if(resultObject == adidSize){ Alert.show("删除成功","提示"); }else if(resultObject >= 0){ var str:String = "选中"+adidSize+"行数据,删除"+resultObject+"条数据!"+(adidSize-resultObject)+"条数据被引用,不能被删除" ; Alert.show(str,"提示"); }else{ Alert.show("删除失败","提示"); } }catch(e:Error){ //表示的是输出的异常 var ex:String = event.result as String ; Alert.show(ex,"提示"); } init(); }else if("AttributeDefineSelectByPrimaryKey" == str){//通过ID查询该对象 var obj:Object = event.result as Object; attributeDefineVO.adid = obj["adid"]; attributeDefineVO.atid = obj["atid"]; attributeDefineVO.ifatom = obj["ifatom"]; attributeDefineVO.ifrelytestcreate = obj["ifrelytestcreate"]; attributeDefineVO.ifrelytestfilter = obj["ifrelytestfilter"]; attributeDefineVO.adcode = obj["adcode"]; attributeDefineVO.adbcode = obj["adbcode"]; attributeDefineVO.name = obj["name"]; attributeDefineVO.shortname = obj["shortname"]; attributeDefineVO.ifsinglenode = obj["ifsinglenode"]; attributeDefineVO.isvalue = obj["isvalue"]; attributeDefineVO.implementation = obj["implementation"]; //声明面板的变量 dTAttrDefineOperBD = PopUpManager.createPopUp(this,objDTAttrDefineOperTitle,true) as objDTAttrDefineOperTitle; //传值 dTAttrDefineOperBD.attributeDefineVO = this.attributeDefineVO ; // 弹出PopUpManager面板 dTAttrDefineOperBD.width=540 ; dTAttrDefineOperBD.height=300 ; //添加事件 为了关闭弹出面板时,刷新父页面 dTAttrDefineOperBD.addEventListener("refursh",refursh); //注册事件 PopUpManager.centerPopUp(dTAttrDefineOperBD); } } private function refursh(event:Event):void{ init(); } /**** * 点击新增(add_button)按钮 * 跳转至该方法 * */ public function add_Function():void{ //声明面板的变量 dTAttrDefineOperBD = new objDTAttrDefineOperTitle(); dTAttrDefineOperBD.addEventListener("refursh",refursh); // 弹出PopUpManager面板 // var helpWindow:IFlexDisplayObject = PopUpManager.createPopUp(this,objDTAttrDefineOperTitle,true); dTAttrDefineOperBD = PopUpManager.createPopUp(this,objDTAttrDefineOperTitle,true) as objDTAttrDefineOperTitle; dTAttrDefineOperBD.height = 400 ; dTAttrDefineOperBD.width=640; dTAttrDefineOperBD.addEventListener("refursh",refursh); PopUpManager.centerPopUp(dTAttrDefineOperBD); } /**** * 用户点击了DataGrid中的修改或者删除的时候 * 调用该方法进行相应的操作 * */ public function detail_changeHandler(event:Event,id:int,status:String):void{ if('update' == status){ //更改 tDTAttributeDefineService.selectByPrimaryKey(id); }else if('delete' == status){ //删除 tDTAttributeDefineService.deleteByPrimaryKey(id); }else{ //点击了详情 加载ufmDTAttrValue的Module // Alert.show("详情","提示"); var url:String = "ui/form/ufmDTAttrValue.swf?parentid="+id ; mouduleloader.url=url ; removeElement(myAttributeDefinePanel); removeElement(hGroupPanel); // removeElement(myNewAttributeDefinePanel); } } /**** * 格式化输出 '是' 或者 '否' * */ private function yesNoVerdict(item:Object,dataGridColumn:DataGridColumn):String{ if("ifatom" == dataGridColumn.dataField){ if("1" == item.ifatom){ return "是" ; }else{ return "否" ; } }else if("ifrelytestcreate" == dataGridColumn.dataField){ if("1" == item.ifrelytestcreate){ return "是" ; }else{ return "否" ; } }else if("ifrelytestfilter" == dataGridColumn.dataField){ if("1" == item.ifrelytestfilter){ return "是" ; }else{ return "否" ; } }else if("ifsinglenode" == dataGridColumn.dataField){ if("1" == item.ifsinglenode){ return "是" ; }else{ return "否" ; } }else if("isvalue" == dataGridColumn.dataField){ if("1" == item.isvalue){ return "是" ; }else{ return "否" ; } } return "" ; } /**** * 导出excel的方法 * */ private function exportExcel():void{ ExportExcel.loadDGInExcel(this.dataGrid,'ExcelExport.jsp'); } /**** * DataGrid的双击事件 * */ private function dataGridDoubleClick(event:ListEvent):void{ var dataGridIndex:int = new int(); dataGridIndex = event.rowIndex; var id:int = attributeDefineList[dataGridIndex].adid; tDTAttributeDefineService.selectByPrimaryKey(id); } /**** * 删除 * */ private function delete_Function():void{ var x:Array = this.dataGrid.selectedIndices ; if(x.length > 0){ adidSize = x.length ; for(var i:int = 0;i<x.length;i++){ var y:int = new int(); y = attributeDefineList.getItemAt(x[i]).adid ; if(i == 0){ adid = "" + y ; }else{ adid = adid + "," + y ; } } // registerClassAlias(("java.util.ArrayList", adid); // Alert.show(adid); tDTAttributeDefineService.deleteAttributeDefineByPKS(adid); }else{ Alert.show("请选择要删除的数据","提示"); } } /** * 退回的方法 * ***/ private function return_Function():void{ ExternalInterface.call("function(){window.location.href='http://localhost:8080/ysdsTas//ysdsTas.html';}"); } /** * 点击详情 * **/ private function detail_Function():void{ var dArray:Array = this.dataGrid.selectedIndices ; // Alert.show(xx + "" ); //没有选择时时-1 var xx:int ; if(dArray.length >1){ Alert.show("只能选择一条数据进行查看"); }else if(dArray.length == 1){ var y:String = attributeDefineList.getItemAt(dArray[0]).adid ; var url:String = "ui/form/ufmDTAttrValue.swf?parentid="+y ; mouduleloader.url=url ; removeElement(myAttributeDefinePanel); removeElement(hGroupPanel); }else{ //表示用户没有选择行 Alert.show("请选择你要查看详情的数据"); } // Alert.show("详情","提示"); } /**** * 导入excel的方法 * */ private function import_Function():void{ ImportUtil.myupload("t_dt_attributeDefine"); //需要一个返回值,判断文件是否是上传成功 } } }
我的mxml文件引用的方式1:
<fx:Script > include "../../com/ysds/sysconf/control/DTAttrDefineAs.as" ; </fx:Script>
我的mxml文件引用的方式2:
<fx:Script source="../../com/ysds/sysconf/control/DTAttrDefineAs.as" > </fx:Script>
但是一直报错,1037:包不能嵌套,
解决方案:
//去掉package,class,这样的就能引用了,mxml中不用带package和class的