<?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:Script> <![CDATA[ import mx.controls.Alert; import mx.collections.ArrayCollection; [Bindable] public var myArray:ArrayCollection = new ArrayCollection(['one','tow','three']); public function showMsg(msg:String):void { mx.controls.Alert.show('你刚刚点击了'+msg); } ]]> </fx:Script> <s:Panel title="我的Panel面板" width="360" height="400" horizontalCenter="0" verticalCenter="0"> <s:layout> <s:HorizontalLayout/> </s:layout> <s:VGroup> <s:Button id="thisBtn" label="Button" click="showMsg('button')" /> <mx:LinkButton id="thisLinkBtn" label="LinkButton" click="showMsg('linkbutton')"/> </s:VGroup> <s:VGroup> <s:ButtonBar id="thisBtnBar" dataProvider="{myArray}" click="showMsg(ButtonBar(event.currentTarget).selectedItem)"/> <mx:LinkBar id="thisLinkBar" dataProvider="{myArray}" itemClick="showMsg(event.label)" /> <mx:ToggleButtonBar id="thisToggleBar" dataProvider="{myArray}" itemClick="showMsg(event.label)" /> </s:VGroup> </s:Panel> </s:Application>