酷符网Flex > 正文

flex LinkButton设置超链接打开网址

2010-07-26 15:18codeif.com

可以在LinkButton中添加一个单击事件,在事件里面加上这段:
navigateToURL(new URLRequest(“http://www.codeif.com/”), “_blank”); 就可以实现超链接了

可以看下面的例子代码

<?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 flash.net.navigateToURL;
			protected function linkbutton1_clickHandler(event:MouseEvent):void
			{
				navigateToURL(new URLRequest("http://www.codeif.com/"),"_blank");
			}
		]]>
	</fx:Script>
	<fx:Declarations>
		<!-- 将非可视元素(例如服务、值对象)放在此处 -->
	</fx:Declarations>
	<s:layout>
		<s:HorizontalLayout horizontalAlign="center" />
	</s:layout>
	<s:Panel title="LinkButton Sample" borderAlpha="0.15" width="600">
		<s:layout>
			<s:VerticalLayout horizontalAlign="center" paddingLeft="10" paddingRight="10" paddingTop="10" paddingBottom="10" />
		</s:layout>
		<s:Label color="0x323232" text="Sample of image embeded at compile time."/>
		<mx:LinkButton label="LinkButton Control" click="linkbutton1_clickHandler(event)" color="0x3380DD" textDecoration="underline" icon="@Embed('assets/arrow_icon_blue.png')" />
	</s:Panel>
</s:Application>

相关文章

新浪微博 | 淘段子 | 我的博客 | 淘宝店铺 | jnan.org | RSS
Copyright © 2009 - 2011 酷符网