<?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="init()" click="application1_clickHandler(event)" xmlns:components="components.*"> <s:layout> <s:BasicLayout/> </s:layout> <fx:Script> <![CDATA[ import mx.collections.ArrayList; var list:mx.controls.List=new mx.controls.List(); protected function init():void{ var arr:ArrayList=new ArrayList(); arr.addItem("百度"); arr.addItem("有道"); arr.addItem("必应"); list.dataProvider=arr; list.x=408; list.y=46; list.width=40; list.height=90; list.id="cityList"; this.addElement(list); list.setVisible(false); list.addEventListener(MouseEvent.CLICK,listClick); } protected function listClick(event:MouseEvent):void{ mylabel.text=list.selectedItem.valueOf(); list.visible=false; var u:URLRequest; if(mylabel.text=="百度"){ u=new URLRequest("http://www.baidu.com"); }else if(mylabel.text=="有道"){ u=new URLRequest("http://www.youdao.com"); }else if(mylabel.text=="必应"){ u=new URLRequest("http://www.bing.com"); } navigateToURL(u);//跳到新窗口 } //注意这里,就是在这里进行事件判断处理 protected function application1_clickHandler(event:MouseEvent):void { if(event.target.id=="linkBtnImg"){ list.visible=true; }else{ list.visible=false; } } ]]> </fx:Script> <s:Label id="mylabel" x="285" y="183"/> <mx:LinkButton id="linkBtnImg" x="285" y="40" icon="@Embed('img/logo.png')" width="116"/> </s:Application>