[code="java"]<?xml version="1.0" encoding="utf-8"?>
mx:Script
<![CDATA[
import mx.controls.Label;
import mx.events.CloseEvent;
import mx.containers.TitleWindow;
import mx.managers.PopUpManager;
private var titleWindow:TitleWindow;
public function init():void {
mx.controls.Alert.show("tests");
var label:Label = new Label();
label.text = "Hello world";
titleWindow = new TitleWindow();
titleWindow.title = "Custom title";
titleWindow.showCloseButton = true;
titleWindow.width = 240;
titleWindow.height = 180;
titleWindow.addEventListener(CloseEvent.CLOSE, titleWindow_close);
titleWindow.addChild(label);
PopUpManager.addPopUp(titleWindow, this, true);
PopUpManager.centerPopUp(titleWindow);
}
private function titleWindow_close(evt:CloseEvent):void {
PopUpManager.removePopUp(titleWindow);
}
]]>
</mx:Script>
<mx:Panel y="46" width="868" height="462" layout="absolute" title="学生教材选订" fontSize="16" fontWeight="bold" horizontalCenter="0" horizontalAlign="right">
<mx:VBox horizontalAlign="right">
<mx:DataGrid id="stuinfogrid" textAlign="left" x="23" y="10" height="400" width="700" editable="true" fontSize="13">
<mx:ArrayCollection>
<mx:Object coursename="软件工程" teachername="马素霞" bookname="软件工程导学"/>
<mx:Object coursename="软件工程" teachername="马素霞" bookname="软件工程导学"/>
<mx:Object coursename="软件工程" teachername="马素霞" bookname="软件工程导学"/>
</mx:ArrayCollection>
<mx:columns>
<mx:DataGridColumn headerText="课程" dataField="coursename"/>
<mx:DataGridColumn headerText="教师" dataField="teachername"/>
<mx:DataGridColumn headerText="教材" dataField="bookname" minWidth="200"/>
<mx:DataGridColumn headerText="教材信息" dataField="bookinfo" textAlign="center" editable="true" width="100">
<mx:itemRenderer>
<mx:Component>
<mx:Button width="30" height="10" fontSize="14" click="init()" label="查看">
</mx:Button>
</mx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
<mx:DataGridColumn headerText="是否订购" dataField="buybook" textAlign="center" itemRenderer="mx.controls.CheckBox" editorDataField="selected" rendererIsEditor="true" minWidth="100" editable="true"/>
</mx:columns>
</mx:DataGrid>
</mx:VBox>
</mx:Panel>
/mx:Application
[/code]
为什么click="init()"不起作用 点击button时程序没有反映。