<?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" creationComplete="application1_creationCompleteHandler(event)"> <s:layout> <s:BasicLayout/> </s:layout> <fx:Script> <!--[CDATA[ import com.firemax.controls.FireMaxAlert; import mx.collections.ArrayCollection; import mx.events.FlexEvent; [Bindable] public var listDemo:ArrayCollection; var stringName:String = new String("李四"); protected function application1_creationCompleteHandler(event:FlexEvent):void { // TODO Auto-generated method stub listDemo=new ArrayCollection(); listDemo.addItem(new String("张三")); listDemo.addItem(stringName); listDemo.addItem(new String("王五")); } protected function button1_clickHandler(event:MouseEvent):void { // TODO Auto-generated method stub stringName="麻子"; FireMaxAlert.show(listDemo.getItemAt(1).toString()); //FireMaxAlert.show(stringName); } ]]--> </fx:Script> <fx:Declarations> <!-- 将非可视元素(例如服务、值对象)放在此处 --> </fx:Declarations> <mx:DataGrid x="46" y="33" width="403" height="212" dataProvider="{listDemo}"> <mx:columns> <mx:DataGridColumn headerText="列 1" dataField="col1"/> </mx:columns> </mx:DataGrid> <s:Button x="46" y="275" label="按钮" click="button1_clickHandler(event)"/> </s:Application>